Micron Document
<!DOCTYPE html>
<html class="client-nojs vector-feature-night-mode-disabled vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-1 vector-sticky-header-enabled" lang="en" dir="ltr"><head>
<meta charset="UTF-8">
<title>Objective-C</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="canonical" href="https://en.wikipedia.org/wiki/Objective-C"> <link href="./mw/ext.cite.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/ext.pygments.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.icons.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.search.codex.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/user.styles.css" rel="stylesheet" type="text/css">
<meta name="ResourceLoaderDynamicStyles" content="">
<link rel="stylesheet" type="text/css" href="./mw/site.styles.css">
<link rel="stylesheet" type="text/css" href="./mw/noscript.css">
<link rel="stylesheet" type="text/css" href="./footer.css">
<link rel="stylesheet" type="text/css" href="./vector-2022.css">
</head>
<body class="skin--responsive skin-vector skin-vector-search-vue mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-0 ns-subject page-Objective-C rootpage-Objective-C skin-vector-2022 action-view">
<div class="mw-page-container">
<div class="mw-page-container-inner">
<div class="mw-content-container">
<main id="content" class="mw-body">
<header class="mw-body-header vector-page-titlebar">
<h1 id="firstHeading" class="firstHeading mw-first-heading">
<span id="openzim-page-title" class="mw-page-title-main"><span class="mw-page-title-main">Objective-C</span></span>
</h1>
</header>
<a id="top"></a>
<div id="bodyContent" class="vector-body ve-init-mw-desktopArticleTarget-targetContainer" aria-labelledby="firstHeading" data-mw-ve-target-container="">
<div id="mw-content-text" class="mw-body-content mw-content-ltr" lang="en" dir="ltr"><div class="mw-content-ltr mw-parser-output" lang="en" dir="ltr">
<p class="mw-empty-elt">
</p>
<style data-mw-deduplicate="TemplateStyles:r1129693374">
/* start https://en.wikipedia.org/ */


.mw-parser-output .hlist dl,.mw-parser-output .hlist ol,.mw-parser-output .hlist ul{margin:0;padding:0}.mw-parser-output .hlist dd,.mw-parser-output .hlist dt,.mw-parser-output .hlist li{margin:0;display:inline}.mw-parser-output .hlist.inline,.mw-parser-output .hlist.inline dl,.mw-parser-output .hlist.inline ol,.mw-parser-output .hlist.inline ul,.mw-parser-output .hlist dl dl,.mw-parser-output .hlist dl ol,.mw-parser-output .hlist dl ul,.mw-parser-output .hlist ol dl,.mw-parser-output .hlist ol ol,.mw-parser-output .hlist ol ul,.mw-parser-output .hlist ul dl,.mw-parser-output .hlist ul ol,.mw-parser-output .hlist ul ul{display:inline}.mw-parser-output .hlist .mw-empty-li{display:none}.mw-parser-output .hlist dt::after{content:": "}.mw-parser-output .hlist dd::after,.mw-parser-output .hlist li::after{content:" · ";font-weight:bold}.mw-parser-output .hlist dd:last-child::after,.mw-parser-output .hlist dt:last-child::after,.mw-parser-output .hlist li:last-child::after{content:none}.mw-parser-output .hlist dd dd:first-child::before,.mw-parser-output .hlist dd dt:first-child::before,.mw-parser-output .hlist dd li:first-child::before,.mw-parser-output .hlist dt dd:first-child::before,.mw-parser-output .hlist dt dt:first-child::before,.mw-parser-output .hlist dt li:first-child::before,.mw-parser-output .hlist li dd:first-child::before,.mw-parser-output .hlist li dt:first-child::before,.mw-parser-output .hlist li li:first-child::before{content:" (";font-weight:normal}.mw-parser-output .hlist dd dd:last-child::after,.mw-parser-output .hlist dd dt:last-child::after,.mw-parser-output .hlist dd li:last-child::after,.mw-parser-output .hlist dt dd:last-child::after,.mw-parser-output .hlist dt dt:last-child::after,.mw-parser-output .hlist dt li:last-child::after,.mw-parser-output .hlist li dd:last-child::after,.mw-parser-output .hlist li dt:last-child::after,.mw-parser-output .hlist li li:last-child::after{content:")";font-weight:normal}.mw-parser-output .hlist ol{counter-reset:listitem}.mw-parser-output .hlist ol>li{counter-increment:listitem}.mw-parser-output .hlist ol>li::before{content:" "counter(listitem)"\a0 "}.mw-parser-output .hlist dd ol>li:first-child::before,.mw-parser-output .hlist dt ol>li:first-child::before,.mw-parser-output .hlist li ol>li:first-child::before{content:" ("counter(listitem)"\a0 "}


/* end https://en.wikipedia.org/ */
</style><style data-mw-deduplicate="TemplateStyles:r1295905060">
/* start https://en.wikipedia.org/ */


.mw-parser-output .infobox-subbox{padding:0;border:none;margin:-3px;width:auto;min-width:100%;font-size:100%;clear:none;float:none;background-color:transparent}.mw-parser-output .infobox-3cols-child{margin:auto}.mw-parser-output .infobox .navbar{font-size:100%}@media screen{html.skin-theme-clientpref-night .mw-parser-output .infobox-full-data:not(.notheme)>div:not(.notheme)[style]{background:#1f1f23!important;color:#f8f9fa}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .infobox-full-data:not(.notheme)>div:not(.notheme)[style]{background:#1f1f23!important;color:#f8f9fa}}@media(min-width:640px){body.skin--responsive .mw-parser-output .infobox-table{display:table!important}body.skin--responsive .mw-parser-output .infobox-table>caption{display:table-caption!important}body.skin--responsive .mw-parser-output .infobox-table>tbody{display:table-row-group}body.skin--responsive .mw-parser-output .infobox-table th,body.skin--responsive .mw-parser-output .infobox-table td{padding-left:inherit;padding-right:inherit}}


/* end https://en.wikipedia.org/ */
</style><table class="infobox vevent"><tbody><tr><th colspan="2" class="infobox-above" style="background-color:#e0e0e0;">Objective-C</th></tr><tr><th scope="row" class="infobox-label"><a href="Programming_paradigm" title="Programming paradigm">Paradigms</a></th><td class="infobox-data"><a href="Reflective_programming" title="Reflective programming">Reflective</a>, <a href="Class-based_programming" title="Class-based programming">class-based</a> <a href="Object-oriented_programming" title="Object-oriented programming">object-oriented</a></td></tr><tr><th scope="row" class="infobox-label">Family</th><td class="infobox-data"><a href="C_(programming_language)" title="C (programming language)">C</a></td></tr><tr><th scope="row" class="infobox-label"><a href="Software_design" title="Software design">Designed&nbsp;by</a></th><td class="infobox-data"><a href="Brad_Cox" title="Brad Cox">Brad Cox</a>, Tom Love</td></tr><tr><th scope="row" class="infobox-label">First&nbsp;appeared</th><td class="infobox-data">1984<span style="display:none">&nbsp;(<span class="bday dtstart published updated">1984</span>)</span></td></tr><tr><td colspan="2" class="infobox-full-data"></td></tr><tr><th scope="row" class="infobox-label" style="white-space: nowrap;"><a href="Software_release_life_cycle" title="Software release life cycle">Stable release</a></th><td class="infobox-data"><div style="margin:0px;">2.0<sup id="cite_ref-1" class="reference"><a href="#cite_note-1"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></a></sup>
</div></td></tr><tr style="display:none"><td colspan="2">
</td></tr><tr><th scope="row" class="infobox-label"><a href="Type_system" title="Type system">Typing discipline</a></th><td class="infobox-data"><a href="Static_typing" class="mw-redirect" title="Static typing">Static</a>, <a href="Dynamic_typing" class="mw-redirect" title="Dynamic typing">dynamic</a>, <a href="Strong_and_weak_typing" title="Strong and weak typing">weak</a></td></tr><tr><th scope="row" class="infobox-label"><a href="Operating_system" title="Operating system">OS</a></th><td class="infobox-data"><a href="Cross-platform_software" title="Cross-platform software">Cross-platform</a></td></tr><tr><th scope="row" class="infobox-label"><a href="Filename_extension" title="Filename extension">Filename extensions</a></th><td class="infobox-data">.h, .m, .mm, .M</td></tr><tr><th scope="row" class="infobox-label">Website</th><td class="infobox-data"><a rel="nofollow" class="external text" href="https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/Introduction/Introduction.html">developer.apple.com</a></td></tr><tr><th colspan="2" class="infobox-header" style="background-color: #EEEEEE;">Major <a href="Programming_language_implementation" title="Programming language implementation">implementations</a></th></tr><tr><td colspan="2" class="infobox-full-data"><a href="Clang" title="Clang">Clang</a>, <a href="GNU_Compiler_Collection" title="GNU Compiler Collection">GCC</a></td></tr><tr><th colspan="2" class="infobox-header" style="background-color: #EEEEEE;">Influenced by</th></tr><tr><td colspan="2" class="infobox-full-data"><a href="C_(programming_language)" title="C (programming language)">C</a>, <a href="Smalltalk" title="Smalltalk">Smalltalk</a></td></tr><tr><th colspan="2" class="infobox-header" style="background-color: #EEEEEE;">Influenced</th></tr><tr><td colspan="2" class="infobox-full-data"><a href="Groovy_(programming_language)" class="mw-redirect" title="Groovy (programming language)">Groovy</a>, <a href="Java_(programming_language)" title="Java (programming language)">Java</a>, <a href="Nu_(programming_language)" title="Nu (programming language)">Nu</a>, Objective-J, TOM, <a href="Swift_(programming_language)" title="Swift (programming language)">Swift</a><sup id="cite_ref-lattner2014_2-0" class="reference"><a href="#cite_note-lattner2014-2"><span class="cite-bracket">[</span>2<span class="cite-bracket">]</span></a></sup></td></tr><tr><td colspan="2" class="infobox-below hlist" style="border-top: 1px solid #aaa; padding-top: 3px;">
<ul><li><span class="noviewer" typeof="mw:File"></span> <a href="https://en.wikibooks.org/wiki/Objective-C_Programming" class="extiw external" title="wikibooks:Objective-C Programming">Objective-C Programming</a> at Wikibooks</li></ul>
</td></tr></tbody></table>
<p><b>Objective-C</b> is a <a href="High-level_programming_language" title="High-level programming language">high-level</a> <a href="General-purpose_programming_language" title="General-purpose programming language">general-purpose</a>, <a href="Object-oriented_programming" title="Object-oriented programming">object-oriented</a> <a href="Programming_language" title="Programming language">programming language</a> that adds <a href="Smalltalk" title="Smalltalk">Smalltalk</a>-style <a href="Message_passing" title="Message passing">message passing</a> (messaging) to the <a href="C_(programming_language)" title="C (programming language)">C</a> programming language.<sup id="cite_ref-3" class="reference"><a href="#cite_note-3"><span class="cite-bracket">[</span>3<span class="cite-bracket">]</span></a></sup> Originally developed by Brad Cox and Tom Love in the early 1980s, it was selected by <a href="NeXT" title="NeXT">NeXT</a> for its <a href="NeXTSTEP" title="NeXTSTEP">NeXTSTEP</a> <a href="Operating_system" title="Operating system">operating system</a>. Due to <a href="Apple_Inc." title="Apple Inc.">Apple</a> <a href="MacOS" title="MacOS">macOS</a>’s direct lineage from NeXTSTEP,<sup id="cite_ref-4" class="reference"><a href="#cite_note-4"><span class="cite-bracket">[</span>4<span class="cite-bracket">]</span></a></sup> Objective-C was the standard language used, supported, and promoted by Apple for developing <a href="MacOS" title="MacOS">macOS</a> and <a href="IOS" title="IOS">iOS</a> applications (via their respective application programming interfaces (<a href="API" title="API">APIs</a>), <a href="Cocoa_(API)" title="Cocoa (API)">Cocoa</a> and <a href="Cocoa_Touch" class="mw-redirect" title="Cocoa Touch">Cocoa Touch</a>) from 1997, when Apple purchased NeXT, until the introduction of the <a href="Swift_(programming_language)" title="Swift (programming language)">Swift</a> language in 2014.<sup id="cite_ref-:0_5-0" class="reference"><a href="#cite_note-:0-5"><span class="cite-bracket">[</span>5<span class="cite-bracket">]</span></a></sup>
</p><p>Objective-C programs developed for non-Apple operating systems or that are not dependent on Apple's APIs may also be compiled for any <a href="Computer_platform" class="mw-redirect" title="Computer platform">platform</a> supported by <a href="GNU" title="GNU">GNU</a> <a href="GNU_Compiler_Collection" title="GNU Compiler Collection">GNU Compiler Collection</a> (GCC) or <a href="LLVM" title="LLVM">LLVM</a>/<a href="Clang" title="Clang">Clang</a>.
</p><p>Objective-C source code 'messaging/implementation' program files usually have <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">.m</code> filename extensions, while Objective-C 'header/interface' files have <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">.h</code> extensions, the same as C header files. Objective-C++ files are denoted with a <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">.mm</code> filename extension.
</p>
<meta property="mw:PageProp/toc">
<div class="mw-heading mw-heading2"><h2 id="History">History</h2></div>
<p>Objective-C was created mainly by <a href="Brad_Cox" title="Brad Cox">Brad Cox</a> and Tom Love in the early 1980s at their company <a href="Stepstone" class="mw-redirect" title="Stepstone">Productivity Products International (PPI)</a>.<sup id="cite_ref-Wired1_6-0" class="reference"><a href="#cite_note-Wired1-6"><span class="cite-bracket">[</span>6<span class="cite-bracket">]</span></a></sup>
</p><p>Leading up to the creation of their company, both had been introduced to <a href="Smalltalk" title="Smalltalk">Smalltalk</a> while at <a href="ITT_Inc." title="ITT Inc.">ITT Corporation</a>'s Programming Technology Center in 1981. The earliest work on Objective-C traces back to around then.<sup id="cite_ref-7" class="reference"><a href="#cite_note-7"><span class="cite-bracket">[</span>7<span class="cite-bracket">]</span></a></sup> Cox was intrigued by problems of true reusability in <a href="Software_engineering" title="Software engineering">software design</a> and programming. He realized that a language like Smalltalk would be invaluable in building development environments for system developers at ITT. However, he and Tom Love also recognized that <a href="Backward_compatibility" title="Backward compatibility">backward compatibility</a> with C was critically important in ITT's telecom engineering milieu.<sup id="cite_ref-love2009_8-0" class="reference"><a href="#cite_note-love2009-8"><span class="cite-bracket">[</span>8<span class="cite-bracket">]</span></a></sup>
</p><p>Cox began writing a pre-processor for <a href="C_(programming_language)" title="C (programming language)">C</a> to add some of the abilities of <a href="Smalltalk" title="Smalltalk">Smalltalk</a>. He soon had a working implementation of an object-oriented extension to the <a href="C_(programming_language)" title="C (programming language)">C</a> language, which he named Object-Oriented Pre-Compiler (OOPC).<sup id="cite_ref-9" class="reference"><a href="#cite_note-9"><span class="cite-bracket">[</span>9<span class="cite-bracket">]</span></a></sup>
Love was hired by <a href="Schlumberger" title="Schlumberger">Schlumberger</a> Research in 1982 and had the opportunity to acquire the first commercial copy of Smalltalk-80, which further influenced the development of their brainchild. To demonstrate that real progress could be made, Cox showed that making interchangeable <a href="Software_component" title="Software component">software components</a> really needed only a few practical changes to existing tools. Specifically, they needed to support <a href="Object_(computer_science)" title="Object (computer science)">objects</a> in a flexible manner, come supplied with a usable set of <a href="Library_(computing)" title="Library (computing)">libraries</a>, and allow for the code (and any resources needed by the code) to be bundled into one <a href="Cross-platform_software" title="Cross-platform software">cross-platform</a> format.
</p><p>Love and Cox eventually formed PPI to commercialize their product, which coupled an Objective-C compiler with class libraries. In 1986, Cox published the main description of Objective-C in its original form in the book <i>Object-Oriented Programming, An Evolutionary Approach</i>. Although he was careful to explain that there is more to the problem of reusability than just what Objective-C provides, the language was often compared feature for feature with other languages.
</p>
<div class="mw-heading mw-heading3"><h3 id="Popularization_through_NeXT">Popularization through NeXT</h3></div>
<p>In 1988, <a href="NeXT" title="NeXT">NeXT</a> licensed Objective-C from StepStone (the new name of PPI, the owner of the Objective-C trademark) and extended the <a href="GNU_Compiler_Collection" title="GNU Compiler Collection">GCC</a> compiler to support Objective-C. NeXT developed the <a href="Application_Kit" class="mw-redirect" title="Application Kit">Application Kit</a> (AppKit) and <a href="Foundation_Kit" title="Foundation Kit">Foundation Kit</a> libraries on which the <a href="NeXTSTEP" title="NeXTSTEP">NeXTSTEP</a> <a href="User_interface" title="User interface">user interface</a> and Interface Builder were based. While the NeXT workstations failed to make a great impact in the marketplace, the tools were widely lauded in the industry. NeXT dropped hardware production and focused on software tools, selling NeXTSTEP (and OPENSTEP) as a platform for custom programming.
</p><p>To circumvent the terms of the <a href="GPL" class="mw-redirect" title="GPL">GPL</a>, NeXT had originally intended to ship the Objective-C frontend separately, allowing the user to link it with GCC to produce the compiler executable. Though initially accepted by <a href="Richard_M._Stallman" class="mw-redirect" title="Richard M. Stallman">Richard M. Stallman</a>, this plan was rejected after Stallman consulted with GNU's lawyers and NeXT agreed to make Objective-C part of GCC.<sup id="cite_ref-10" class="reference"><a href="#cite_note-10"><span class="cite-bracket">[</span>10<span class="cite-bracket">]</span></a></sup>
</p><p>The work to extend <a href="GNU_Compiler_Collection" title="GNU Compiler Collection">GNU Compiler Collection</a> (GCC) was led by Steve Naroff, who joined NeXT from StepStone. The compiler changes were made available as per <a href="GNU_General_Public_License" title="GNU General Public License">GNU General Public License</a> (GPL) terms, but the <a href="Execution_(computing)#Runtime" title="Execution (computing)">runtime</a> libraries were not, rendering the open source contribution unusable to the general public. This led to other parties developing such runtime libraries under open source licenses. Later, Steve Naroff was also principal contributor to work at Apple to build the Objective-C frontend to <a href="Clang" title="Clang">Clang</a>.
</p><p>The <a href="GNU" title="GNU">GNU</a> project started work on its free software implementation of <a href="Cocoa_(API)" title="Cocoa (API)">Cocoa</a>, named <a href="GNUstep" title="GNUstep">GNUstep</a>, based on the <a href="OpenStep" title="OpenStep">OpenStep</a> standard.<sup id="cite_ref-GNUstep_site_11-0" class="reference"><a href="#cite_note-GNUstep_site-11"><span class="cite-bracket">[</span>11<span class="cite-bracket">]</span></a></sup> Dennis Glatting wrote the first GNU Objective-C <a href="Run_time_system" class="mw-redirect" title="Run time system">runtime</a> in 1992. The current GNU Objective-C runtime, in use since 1993, is the one developed by Kresten Krab Thorup while he was a university student in <a href="Denmark" title="Denmark">Denmark</a>. Thorup also worked at NeXT from 1993 to 1996.<sup id="cite_ref-12" class="reference"><a href="#cite_note-12"><span class="cite-bracket">[</span>12<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading3"><h3 id="Apple_development_and_Swift">Apple development and Swift</h3></div>
<p>After acquiring NeXT in 1996, <a href="Apple_Computer" class="mw-redirect" title="Apple Computer">Apple Computer</a> used OpenStep in its then-new operating system, <a href="Mac_OS_X" class="mw-redirect" title="Mac OS X">Mac OS X</a>. This included Objective-C, NeXT's Objective-C-based developer tool, <a href="Project_Builder" title="Project Builder">Project Builder</a>, and its interface design tool, <a href="Interface_Builder" title="Interface Builder">Interface Builder</a>. Both were later merged into one application, <a href="Xcode" title="Xcode">Xcode</a>. Most of Apple's current <a href="Cocoa_(API)" title="Cocoa (API)">Cocoa API</a> is based on OpenStep interface objects and is the most significant Objective-C environment being used for active development.
</p><p>At <a href="WWDC" class="mw-redirect" title="WWDC">WWDC</a> 2014, Apple introduced a new language, <a href="Swift_(programming_language)" title="Swift (programming language)">Swift</a>, which was characterized as "Objective-C without the C".
</p>
<div class="mw-heading mw-heading2"><h2 id="Syntax">Syntax</h2></div>
<p>Objective-C is a thin layer atop <a href="C_(programming_language)" title="C (programming language)">C</a> and is a "strict <a href="Superset" class="mw-redirect" title="Superset">superset</a>" of C, meaning that it is possible to compile any C program with an Objective-C compiler and to freely include C language code within an Objective-C class.<sup id="cite_ref-13" class="reference"><a href="#cite_note-13"><span class="cite-bracket">[</span>13<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-14" class="reference"><a href="#cite_note-14"><span class="cite-bracket">[</span>14<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-15" class="reference"><a href="#cite_note-15"><span class="cite-bracket">[</span>15<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-16" class="reference"><a href="#cite_note-16"><span class="cite-bracket">[</span>16<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-17" class="reference"><a href="#cite_note-17"><span class="cite-bracket">[</span>17<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-18" class="reference"><a href="#cite_note-18"><span class="cite-bracket">[</span>18<span class="cite-bracket">]</span></a></sup>
</p><p>Objective-C derives its object syntax from <a href="Smalltalk" title="Smalltalk">Smalltalk</a>. All of the syntax for non-object-oriented operations (including primitive variables, pre-processing, expressions, function declarations, and function calls) are identical to those of C, while the syntax for object-oriented features is an implementation of Smalltalk-style messaging.
</p>
<div class="mw-heading mw-heading3"><h3 id="Messages">Messages</h3></div>
<p>The Objective-C model of object-oriented programming is based on <a href="Message_passing" title="Message passing">message passing</a> to object instances. In Objective-C, one does not <i>call a method</i>; one <i>sends a message</i>. This is unlike the <a href="Simula" title="Simula">Simula</a>-style programming model used by <a href="C%2B%2B" title="C++">C++</a>. The difference between these two concepts is in how the code referenced by the method or message name is executed. In a Simula-style language, the method name is—in most cases—<a href="Name_binding" title="Name binding">bound</a> to a section of code in the target class by the compiler. In <a href="Smalltalk" title="Smalltalk">Smalltalk</a> and Objective-C, the target of a message is resolved at runtime, with the receiving object itself interpreting the message. A method is identified by a <i>selector</i> or <a rel="nofollow" class="external text" href="https://developer.apple.com/documentation/objectivec/sel?language=occ"><code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">SEL</code></a> — a unique identifier for each message name, often just a <a href="Null-terminated_string" title="Null-terminated string"><code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">NUL</code>-terminated string</a> representing its name—and resolved to a C method <a href="Pointer_(computer_programming)" title="Pointer (computer programming)">pointer</a> implementing it: an <a rel="nofollow" class="external text" href="https://developer.apple.com/documentation/objectivec/objective-c_runtime/imp?language=occ"><code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">IMP</code></a>.<sup id="cite_ref-19" class="reference"><a href="#cite_note-19"><span class="cite-bracket">[</span>19<span class="cite-bracket">]</span></a></sup> A consequence of this is that the message-passing system has no type checking. The object to which the message is directed—the <i>receiver</i>—is not guaranteed to respond to a message, and if it does not, it raises an exception.<sup id="cite_ref-20" class="reference"><a href="#cite_note-20"><span class="cite-bracket">[</span>20<span class="cite-bracket">]</span></a></sup>
</p><p>Sending the message <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">method</code> to the object pointed to by the pointer <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">obj</code> would require the following code in <a href="C%2B%2B" title="C++">C++</a>:
</p>
<div class="mw-highlight mw-highlight-lang-cpp mw-content-ltr" dir="ltr"><pre><span class="n">obj</span><span class="o">-&gt;</span><span class="n">method</span><span class="p">(</span><span class="n">argument</span><span class="p">);</span>
</pre></div>
<p>In Objective-C, this is written as follows:
</p>
<div class="mw-highlight mw-highlight-lang-objc mw-content-ltr" dir="ltr"><pre><span class="p">[</span><span class="n">obj</span><span class="w"> </span><span class="n">method</span><span class="o">:</span><span class="n">argument</span><span class="p">];</span>
</pre></div>
<p>The "method" call is translated by the compiler to the <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">objc_msgSend(id self, SEL op, ...)</code> family of runtime functions. Different implementations handle modern additions like <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">super</code>.<sup id="cite_ref-21" class="reference"><a href="#cite_note-21"><span class="cite-bracket">[</span>21<span class="cite-bracket">]</span></a></sup> In GNU families, this function is named <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">objc_msg_sendv</code>, but it has been deprecated in favor of a modern lookup system under <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">objc_msg_lookup</code>.<sup id="cite_ref-22" class="reference"><a href="#cite_note-22"><span class="cite-bracket">[</span>22<span class="cite-bracket">]</span></a></sup>
</p><p>Both styles of programming have multiple strengths and weaknesses. <a href="Object-oriented_programming" title="Object-oriented programming">Object-oriented programming</a> in the Simula (<a href="C%2B%2B" title="C++">C++</a>) style allows <a href="Multiple_inheritance" title="Multiple inheritance">multiple inheritance</a> and faster execution by using <a href="Compile-time_binding" class="mw-redirect" title="Compile-time binding">compile-time binding</a> whenever possible, but it does not support <a href="Dynamic_dispatch" title="Dynamic dispatch">dynamic binding</a> by default. It also forces all methods to have a corresponding implementation unless they are <a href="Abstract_method" class="mw-redirect" title="Abstract method">abstract</a>. The Smalltalk-style programming as used in Objective-C allows messages to go unimplemented, with the method resolved to its implementation at runtime. For example, a message may be sent to a collection of objects, to which only some will be expected to respond, without fear of producing runtime errors. Message passing also does not require that an object be defined at <a href="Compile_time" title="Compile time">compile time</a>. An implementation is still required for the method to be called in the derived object. (See the <a href="#Dynamic_typing">dynamic typing</a> section below for more advantages of dynamic (late) binding.)
</p>
<div class="mw-heading mw-heading3"><h3 id="Interfaces_and_implementations">Interfaces and implementations</h3></div>
<p>Objective-C requires that the <a href="Interface_(computing)" title="Interface (computing)">interface</a> and implementation of a class be in separately declared code blocks. By convention, developers place the interface in a <a href="Header_file" class="mw-redirect" title="Header file">header file</a> and the implementation in a code file. The header files, normally suffixed .h, are similar to C header files while the implementation (method) files, normally suffixed .m, can be very similar to C code files.
</p>
<div class="mw-heading mw-heading4"><h4 id="Interface">Interface</h4></div>
<p>This is analogous to class declarations as used in other object-oriented languages, such as C++ or Python.
</p><p>The interface of a class is usually defined in a header file. A common convention is to name the header file after the name of the class, e.g. <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">Ball.h</code> would contain the interface for the class <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">Ball</code>.
</p><p>An interface declaration takes the form:
</p>
<div class="mw-highlight mw-highlight-lang-objc mw-content-ltr" dir="ltr"><pre><span class="k">@interface</span> <span class="nc">ClassName</span>&nbsp;: <span class="nc">SuperclassName</span> <span class="p">{</span>
<span class="w"> </span><span class="c1">// instance variables</span>
<span class="p">}</span>
<span class="p">+</span> <span class="nf">classMethod1</span><span class="p">;</span>
<span class="p">+</span> <span class="p">(</span><span class="n">return_type</span><span class="p">)</span><span class="nf">classMethod2</span><span class="p">;</span>
<span class="p">+</span> <span class="p">(</span><span class="n">return_type</span><span class="p">)</span><span class="nf">classMethod3:</span><span class="p">(</span><span class="n">param1_type</span><span class="p">)</span><span class="nv">param1_varName</span><span class="p">;</span>

<span class="p">-</span> <span class="p">(</span><span class="n">return_type</span><span class="p">)</span><span class="nf">instanceMethod1With1Parameter:</span><span class="p">(</span><span class="n">param1_type</span><span class="p">)</span><span class="nv">param1_varName</span><span class="p">;</span>
<span class="p">-</span> <span class="p">(</span><span class="n">return_type</span><span class="p">)</span><span class="nf">instanceMethod2With2Parameters:</span><span class="p">(</span><span class="n">param1_type</span><span class="p">)</span><span class="nv">param1_varName</span>
<span class="w"> </span><span class="nl">param2_callName</span><span class="p">:(</span><span class="n">param2_type</span><span class="p">)</span><span class="nv">param2_varName</span><span class="p">;</span>
<span class="k">@end</span>
</pre></div>
<p>In the above, plus signs denote <a href="Class_method" class="mw-redirect" title="Class method">class methods</a>, or methods that can be called on the class itself (not on an instance), and minus signs denote <a href="Instance_method" class="mw-redirect" title="Instance method">instance methods</a>, which can only be called on a particular instance of the class. Class methods also have no access to <a href="Instance_variable" title="Instance variable">instance variables</a>.
</p><p>The code above is roughly equivalent to the following <a href="C%2B%2B" title="C++">C++</a> interface:
</p>
<div class="mw-highlight mw-highlight-lang-cpp mw-content-ltr" dir="ltr"><pre><span class="k">class</span><span class="w"> </span><span class="nc">ClassName</span><span class="w"> </span><span class="o">:</span><span class="w"> </span><span class="k">public</span><span class="w"> </span><span class="n">SuperclassName</span><span class="w"> </span><span class="p">{</span>
<span class="k">protected</span><span class="o">:</span>
<span class="w"> </span><span class="c1">// instance variables</span>

<span class="k">public</span><span class="o">:</span>
<span class="w"> </span><span class="c1">// Class (static) functions</span>
<span class="w"> </span><span class="k">static</span><span class="w"> </span><span class="kt">void</span><span class="w"> </span><span class="o">*</span><span class="n">classMethod1</span><span class="p">();</span>
<span class="w"> </span><span class="k">static</span><span class="w"> </span><span class="n">return_type</span><span class="w"> </span><span class="nf">classMethod2</span><span class="p">();</span>
<span class="w"> </span><span class="k">static</span><span class="w"> </span><span class="n">return_type</span><span class="w"> </span><span class="nf">classMethod3</span><span class="p">(</span><span class="n">param1_type</span><span class="w"> </span><span class="n">param1_varName</span><span class="p">);</span>

<span class="w"> </span><span class="c1">// Instance (member) functions</span>
<span class="w"> </span><span class="n">return_type</span><span class="w"> </span><span class="nf">instanceMethod1With1Parameter</span><span class="p">(</span><span class="n">param1_type</span><span class="w"> </span><span class="n">param1_varName</span><span class="p">);</span>
<span class="w"> </span><span class="n">return_type</span>
<span class="w"> </span><span class="nf">instanceMethod2With2Parameters</span><span class="p">(</span><span class="n">param1_type</span><span class="w"> </span><span class="n">param1_varName</span><span class="p">,</span>
<span class="w"> </span><span class="n">param2_type</span><span class="w"> </span><span class="n">param2_varName</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">default</span><span class="p">);</span>
<span class="p">};</span>
</pre></div>
<p>Note that <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">instanceMethod2With2Parameters:param2_callName:</code> demonstrates the interleaving of selector segments with argument expressions, for which there is no direct equivalent in C/C++.
</p><p>Return types can be any standard <a href="C_(programming_language)" title="C (programming language)">C</a> type, a pointer to a generic Objective-C object, a pointer to a specific type of object such as NSArray *, NSImage *, or NSString *, or a pointer to the class to which the method belongs (instancetype). The default return type is the generic Objective-C type <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">id</code>.
</p><p>Method arguments begin with a name labeling the argument that is part of the method name, followed by a colon followed by the expected argument type in parentheses and the argument name. The label can be omitted.
</p>
<div class="mw-highlight mw-highlight-lang-objc mw-content-ltr" dir="ltr"><pre><span class="p">-</span> <span class="p">(</span><span class="kt">void</span><span class="p">)</span><span class="nf">setRangeStart:</span><span class="p">(</span><span class="kt">int</span><span class="p">)</span><span class="nv">start</span><span class="w"> </span><span class="nf">end:</span><span class="p">(</span><span class="kt">int</span><span class="p">)</span><span class="nv">end</span><span class="p">;</span>
<span class="p">-</span> <span class="p">(</span><span class="kt">void</span><span class="p">)</span><span class="nf">importDocumentWithName:</span><span class="p">(</span><span class="bp">NSString</span><span class="w"> </span><span class="o">*</span><span class="p">)</span><span class="nv">name</span>
<span class="w"> </span><span class="nl">withSpecifiedPreferences</span><span class="p">:(</span><span class="n">Preferences</span><span class="w"> </span><span class="o">*</span><span class="p">)</span><span class="nv">prefs</span>
<span class="w"> </span><span class="nl">beforePage</span><span class="p">:(</span><span class="kt">int</span><span class="p">)</span><span class="nv">insertPage</span><span class="p">;</span>
</pre></div>
<p>A derivative of the interface definition is the <i>category</i>, which allows one to add methods to existing classes.<sup id="cite_ref-23" class="reference"><a href="#cite_note-23"><span class="cite-bracket">[</span>23<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading4"><h4 id="Implementation">Implementation</h4></div>
<p>The interface only declares the class interface and not the methods themselves: the actual code is written in the implementation file. Implementation (method) files normally have the file extension <code>.m</code>, which originally signified "messages".<sup id="cite_ref-24" class="reference"><a href="#cite_note-24"><span class="cite-bracket">[</span>24<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-highlight mw-highlight-lang-objc mw-content-ltr" dir="ltr"><pre><span class="k">@implementation</span> <span class="nc">classname</span>
<span class="p">+</span> <span class="p">(</span><span class="n">return_type</span><span class="p">)</span><span class="nf">classMethod</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="c1">// implementation</span>
<span class="p">}</span>
<span class="p">-</span> <span class="p">(</span><span class="n">return_type</span><span class="p">)</span><span class="nf">instanceMethod</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="c1">// implementation</span>
<span class="p">}</span>
<span class="k">@end</span>
</pre></div>
<p>Methods are written using their interface declarations.
Comparing Objective-C and C:
</p>
<div class="mw-highlight mw-highlight-lang-objc mw-content-ltr" dir="ltr"><pre><span class="p">-</span> <span class="p">(</span><span class="kt">int</span><span class="p">)</span><span class="nf">method:</span><span class="p">(</span><span class="kt">int</span><span class="p">)</span><span class="nv">i</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="p">[</span><span class="nb">self</span><span class="w"> </span><span class="n">square_root</span><span class="o">:</span><span class="n">i</span><span class="p">];</span>
<span class="p">}</span>
</pre></div>
<div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span class="kt">int</span><span class="w"> </span><span class="nf">function</span><span class="p">(</span><span class="kt">int</span><span class="w"> </span><span class="n">i</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="n">square_root</span><span class="p">(</span><span class="n">i</span><span class="p">);</span>
<span class="p">}</span>
</pre></div>
<p>The syntax allows pseudo-<a href="Named_parameter" title="Named parameter">naming of arguments</a>.
</p>
<div class="mw-highlight mw-highlight-lang-objc mw-content-ltr" dir="ltr"><pre><span class="p">-</span> <span class="p">(</span><span class="kt">void</span><span class="p">)</span><span class="nf">changeColorToRed:</span><span class="p">(</span><span class="kt">float</span><span class="p">)</span><span class="nv">red</span><span class="w"> </span><span class="nf">green:</span><span class="p">(</span><span class="kt">float</span><span class="p">)</span><span class="nv">green</span><span class="w"> </span><span class="nf">blue:</span><span class="p">(</span><span class="kt">float</span><span class="p">)</span><span class="nv">blue</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="c1">//... Implementation ...</span>
<span class="p">}</span>

<span class="c1">// Called like so:</span>
<span class="p">[</span><span class="n">myColor</span><span class="w"> </span><span class="n">changeColorToRed</span><span class="o">:</span><span class="mf">5.0</span><span class="w"> </span><span class="n">green</span><span class="o">:</span><span class="mf">2.0</span><span class="w"> </span><span class="n">blue</span><span class="o">:</span><span class="mf">6.0</span><span class="p">];</span>
</pre></div>
<p>Internal representations of a method vary between different implementations of Objective-C. If myColor is of the class <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">Color</code>, instance method <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">-changeColorToRed:green:blue:</code> might be internally labeled <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">_i_Color_changeColorToRed_green_blue</code>. The <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">i</code> is to refer to an instance method, with the class and then method names appended and colons changed to underscores. As the order of parameters is part of the method name, it cannot be changed to suit coding style or expression as with true named parameters.
</p><p>However, internal names of the function are rarely used directly. Generally, messages are converted to function calls defined in the Objective-C runtime library. It is not necessarily known at link time which method will be called because the class of the receiver (the object being sent the message) need not be known until runtime.
</p>
<div class="mw-heading mw-heading4"><h4 id="Instantiation">Instantiation</h4></div>
<p>Once an Objective-C class is written, it can be instantiated. This is done by first allocating an uninitialized instance of the class (an object) and then by initializing it. An object is not fully functional until both steps have been completed. These steps should be accomplished with one line of code so that there is never an allocated object that hasn't undergone initialization (and because it is unwise to keep the intermediate result since <code>-init</code> can return a different object than that on which it is called).
</p><p>Instantiation with the default, no-parameter initializer:
</p>
<div class="mw-highlight mw-highlight-lang-objc mw-content-ltr" dir="ltr"><pre><span class="n">MyObject</span><span class="w"> </span><span class="o">*</span><span class="n">foo</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[[</span><span class="n">MyObject</span><span class="w"> </span><span class="n">alloc</span><span class="p">]</span><span class="w"> </span><span class="n">init</span><span class="p">];</span>
</pre></div>
<p>Instantiation with a custom initializer:
</p>
<div class="mw-highlight mw-highlight-lang-objc mw-content-ltr" dir="ltr"><pre><span class="n">MyObject</span><span class="w"> </span><span class="o">*</span><span class="n">foo</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[[</span><span class="n">MyObject</span><span class="w"> </span><span class="n">alloc</span><span class="p">]</span><span class="w"> </span><span class="n">initWithString</span><span class="o">:</span><span class="n">myString</span><span class="p">];</span>
</pre></div>
<p>In the case where no custom initialization is being performed, the "new" method can often be used in place of the alloc-init messages:
</p>
<div class="mw-highlight mw-highlight-lang-objc mw-content-ltr" dir="ltr"><pre><span class="n">MyObject</span><span class="w"> </span><span class="o">*</span><span class="n">foo</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="n">MyObject</span><span class="w"> </span><span class="n">new</span><span class="p">];</span>
</pre></div>
<p>Also, some classes implement class method initializers. Like <code>+new</code>, they combine <code>+alloc</code> and <code>-init</code>, but unlike <code>+new</code>, they return an autoreleased instance. Some class method initializers take parameters:
</p>
<div class="mw-highlight mw-highlight-lang-objc mw-content-ltr" dir="ltr"><pre><span class="n">MyObject</span><span class="w"> </span><span class="o">*</span><span class="n">foo</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="n">MyObject</span><span class="w"> </span><span class="n">object</span><span class="p">];</span>
<span class="n">MyObject</span><span class="w"> </span><span class="o">*</span><span class="n">bar</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="n">MyObject</span><span class="w"> </span><span class="n">objectWithString</span><span class="o">:</span><span class="s">@"Wikipedia&nbsp;:)"</span><span class="p">];</span>
</pre></div>
<p>The <i>alloc</i> message allocates enough memory to hold all the instance variables for an object, sets all the instance variables to zero values, and turns the memory into an instance of the class; at no point during the initialization is the memory an instance of the superclass.
</p><p>The <i>init</i> message performs the set-up of the instance upon creation. The <i>init</i> method is often written as follows:
</p>
<div class="mw-highlight mw-highlight-lang-objc mw-content-ltr mw-highlight-lines" dir="ltr"><pre><span class="p">-</span> <span class="p">(</span><span class="kt">id</span><span class="p">)</span><span class="nf">init</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="nb">self</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="nb">super</span><span class="w"> </span><span class="n">init</span><span class="p">];</span>
<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nb">self</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="c1">// perform initialization of object here</span>
<span class="w"> </span><span class="p">}</span>
<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="nb">self</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
<p>In the above example, notice the <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">id</code> return type. This type stands for <i>pointer to any object</i> in Objective-C (See the <a href="#Dynamic_typing">Dynamic typing</a> section).
</p><p>The initializer pattern is used to assure that the object is properly initialized by its superclass before the init method performs its initialization. It performs the following actions:
</p>
<ul><li>Line 2
<dl><dd>Sends the superclass instance an <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">init</code> message and assigns the result to <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">self</code> (pointer to the current object).</dd></dl></li>
<li>Line 3
<dl><dd>Checks if the returned object pointer is valid before performing any initialization.</dd></dl></li>
<li>Line 6
<dl><dd>Returns the value of self to the caller.</dd></dl></li></ul>
<p>A non-valid object pointer has the value <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">nil</code>; conditional statements like <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">if</code> treat nil like a null pointer, so the initialization code will not be executed if <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">[super init]</code> returned nil. If there is an error in initialization, the init method should perform any necessary cleanup, including sending a <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">release</code> message to self, and return <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">nil</code> to indicate that initialization failed. Any checking for such errors must only be performed after having called the superclass initialization to ensure that destroying the object will be done correctly.
</p><p>If a class has more than one initialization method, only one of them (the <i>designated initializer</i>) needs to follow this pattern; others should call the designated initializer instead of the superclass initializer.
</p>
<div class="mw-heading mw-heading3"><h3 id="Protocols">Protocols</h3></div>
<p>In other programming languages, these are called <i>interfaces</i>.
</p><p>Objective-C was extended at <a href="NeXT" title="NeXT">NeXT</a> to introduce the concept of <a href="Multiple_inheritance" title="Multiple inheritance">multiple inheritance</a> of specification, but not implementation, through the introduction of <a href="Interface_(object-oriented_programming)" title="Interface (object-oriented programming)">protocols</a>. This is a pattern achievable either as an abstract multiple inherited base class in <a href="C%2B%2B" title="C++">C++</a>, or as an <i>interface</i> (as in Java and <a href="C_Sharp_(programming_language)" title="C Sharp (programming language)">C#</a>). Objective-C makes use of ad hoc protocols called <i>informal protocols</i> and compiler-enforced protocols called <i>formal protocols</i>.
</p><p>An informal protocol is a list of methods that a class can opt to implement. It is specified in the documentation, since it has no presence in the language. Informal protocols are implemented as a <a class="mw-selflink-fragment" href="#Categories">category</a> (see below) on NSObject and often include optional methods, which, if implemented, can change the behavior of a class. For example, a text field class might have a <a href="Delegation_(programming)" class="mw-redirect" title="Delegation (programming)">delegate</a> that implements an informal protocol with an optional method for performing auto-completion of user-typed text. The text field discovers whether the delegate implements that method (via <a href="Reflective_programming" title="Reflective programming">reflective programming</a> (reflection)) and, if so, calls the delegate's method to support the auto-complete feature.
</p><p>A formal protocol is similar to an <a href="Interface_(computing)" title="Interface (computing)">interface</a> in Java, C#, and <a href="Ada_(programming_language)" title="Ada (programming language)">Ada 2005</a>. It is a list of methods that any class can declare itself to implement. Objective-C versions before 2.0 required that a class must implement all methods in a protocol it declares itself as adopting; the compiler will emit an error if the class does not implement every method from its declared protocols. Objective-C 2.0 added support for marking certain methods in a protocol optional, and the compiler will not enforce implementation of optional methods.
</p><p>A class must be declared to implement that protocol to be said to conform to it. This is detectable at runtime. Formal protocols cannot provide any implementations; they simply assure callers that classes that conform to the protocol will provide implementations. In the NeXT/Apple library, protocols are frequently used by the Distributed Objects system to represent the abilities of an object executing on a remote system.
</p><p>The syntax
</p>
<div class="mw-highlight mw-highlight-lang-objc mw-content-ltr" dir="ltr"><pre><span class="k">@protocol</span> <span class="bp">NSLocking</span>
<span class="p">-</span> <span class="p">(</span><span class="kt">void</span><span class="p">)</span><span class="nf">lock</span><span class="p">;</span>
<span class="p">-</span> <span class="p">(</span><span class="kt">void</span><span class="p">)</span><span class="nf">unlock</span><span class="p">;</span>
<span class="k">@end</span>
</pre></div>
<p>denotes that there is the abstract idea of locking. By stating in the class definition that the protocol is implemented,
</p>
<div class="mw-highlight mw-highlight-lang-objc mw-content-ltr" dir="ltr"><pre><span class="k">@interface</span> <span class="bp">NSLock</span>&nbsp;: <span class="bp">NSObject</span><span class="w"> </span><span class="o">&lt;</span><span class="bp">NSLocking</span><span class="o">&gt;</span>
<span class="c1">// ...</span>
<span class="k">@end</span>
</pre></div>
<p>instances of NSLock claim that they will provide an implementation for the two instance methods.
</p>
<div class="mw-heading mw-heading3"><h3 id="Dynamic_typing">Dynamic typing</h3></div>
<p>Objective-C, like Smalltalk, can use <a href="Dynamic_typing" class="mw-redirect" title="Dynamic typing">dynamic typing</a>: an object can be sent a message that is not specified in its interface. This can allow for increased flexibility, as it allows an object to "capture" a message and send the message to a different object that can respond to the message appropriately, or likewise send the message on to another object. This behavior is known as <i>message forwarding</i> or <i>delegation</i> (see below). Alternatively, an error handler can be used in case the message cannot be forwarded. If an object does not forward a message, respond to it, or handle an error, then the system will generate a runtime exception.<sup id="cite_ref-25" class="reference"><a href="#cite_note-25"><span class="cite-bracket">[</span>25<span class="cite-bracket">]</span></a></sup> If messages are sent to <i>nil</i> (the null object pointer), they will be silently ignored or raise a generic exception, depending on compiler options.
</p><p>Static typing information may also optionally be added to variables. This information is then checked at compile time. In the following four statements, increasingly specific type information is provided. The statements are equivalent at runtime, but the extra information allows the compiler to warn the programmer if the passed argument does not match the type specified.
</p>
<div class="mw-highlight mw-highlight-lang-objc mw-content-ltr" dir="ltr"><pre><span class="p">-</span> <span class="p">(</span><span class="kt">void</span><span class="p">)</span><span class="nf">setMyValue:</span><span class="p">(</span><span class="kt">id</span><span class="p">)</span><span class="nv">foo</span><span class="p">;</span>
</pre></div>
<p>In the above statement, <i>foo</i> may be of any class.
</p>
<div class="mw-highlight mw-highlight-lang-objc mw-content-ltr" dir="ltr"><pre><span class="p">-</span> <span class="p">(</span><span class="kt">void</span><span class="p">)</span><span class="nf">setMyValue:</span><span class="p">(</span><span class="kt">id</span><span class="o">&lt;</span><span class="bp">NSCopying</span><span class="o">&gt;</span><span class="p">)</span><span class="nv">foo</span><span class="p">;</span>
</pre></div>
<p>In the above statement, <i>foo</i> may be an instance of any class that conforms to the <i><code>NSCopying</code></i> protocol.
</p>
<div class="mw-highlight mw-highlight-lang-objc mw-content-ltr" dir="ltr"><pre><span class="p">-</span> <span class="p">(</span><span class="kt">void</span><span class="p">)</span><span class="nf">setMyValue:</span><span class="p">(</span><span class="bp">NSNumber</span><span class="w"> </span><span class="o">*</span><span class="p">)</span><span class="nv">foo</span><span class="p">;</span>
</pre></div>
<p>In the above statement, <i>foo</i> must be an instance of the <i>NSNumber</i> class.
</p>
<div class="mw-highlight mw-highlight-lang-objc mw-content-ltr" dir="ltr"><pre><span class="p">-</span> <span class="p">(</span><span class="kt">void</span><span class="p">)</span><span class="nf">setMyValue:</span><span class="p">(</span><span class="bp">NSNumber</span><span class="o">&lt;</span><span class="bp">NSCopying</span><span class="o">&gt;</span><span class="w"> </span><span class="o">*</span><span class="p">)</span><span class="nv">foo</span><span class="p">;</span>
</pre></div>
<p>In the above statement, <i>foo</i> must be an instance of the <i>NSNumber</i> class, and it must conform to the <i><code>NSCopying</code></i> protocol.
</p><p>In Objective-C, all objects are represented as pointers, and static initialization is not allowed. The simplest object is the type that <style data-mw-deduplicate="TemplateStyles:r886049734">
/* start https://en.wikipedia.org/ */


.mw-parser-output .monospaced{font-family:monospace,monospace}


/* end https://en.wikipedia.org/ */
</style><span class="monospaced">id</span> (<span class="monospaced">objc_obj *</span>) points to, which only has an <i>isa</i> pointer describing its class. Other types from C, like values and structs, are unchanged because they are not part of the object system. This decision differs from the C++ object model, where structs and classes are united.
</p>
<div class="mw-heading mw-heading3"><h3 id="Forwarding">Forwarding</h3></div>
<p>Objective-C permits the sending of a message to an object that may not respond. Rather than responding or simply dropping the message, an object can forward the message to an object that can respond. Forwarding can be used to simplify implementation of certain <a href="Design_pattern_(computer_science)" class="mw-redirect" title="Design pattern (computer science)">design patterns</a>, such as the <a href="Observer_pattern" title="Observer pattern">observer pattern</a> or the <a href="Proxy_pattern" title="Proxy pattern">proxy pattern</a>.
</p><p>The Objective-C runtime specifies a pair of methods in <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">Object</code>
</p>
<ul><li>forwarding methods:<div class="mw-highlight mw-highlight-lang-objc mw-content-ltr" dir="ltr"><pre><span class="p">-</span> <span class="p">(</span><span class="n">retval_t</span><span class="p">)</span><span class="nf">forward:</span><span class="p">(</span><span class="kt">SEL</span><span class="p">)</span><span class="nv">sel</span><span class="w"> </span><span class="nf">args:</span><span class="p">(</span><span class="n">arglist_t</span><span class="p">)</span><span class="nv">args</span><span class="p">;</span><span class="w"> </span><span class="c1">// with GCC</span>
<span class="p">-</span> <span class="p">(</span><span class="kt">id</span><span class="p">)</span><span class="nf">forward:</span><span class="p">(</span><span class="kt">SEL</span><span class="p">)</span><span class="nv">sel</span><span class="w"> </span><span class="nf">args:</span><span class="p">(</span><span class="n">marg_list</span><span class="p">)</span><span class="nv">args</span><span class="p">;</span><span class="w"> </span><span class="c1">// with NeXT/Apple systems</span>
</pre></div></li>
<li>action methods:<div class="mw-highlight mw-highlight-lang-objc mw-content-ltr" dir="ltr"><pre><span class="p">-</span> <span class="p">(</span><span class="n">retval_t</span><span class="p">)</span><span class="nf">performv:</span><span class="p">(</span><span class="kt">SEL</span><span class="p">)</span><span class="nv">sel</span><span class="w"> </span><span class="nf">args:</span><span class="p">(</span><span class="n">arglist_t</span><span class="p">)</span><span class="nv">args</span><span class="p">;</span><span class="w"> </span><span class="c1">// with GCC</span>
<span class="p">-</span> <span class="p">(</span><span class="kt">id</span><span class="p">)</span><span class="nf">performv:</span><span class="p">(</span><span class="kt">SEL</span><span class="p">)</span><span class="nv">sel</span><span class="w"> </span><span class="nf">args:</span><span class="p">(</span><span class="n">marg_list</span><span class="p">)</span><span class="nv">args</span><span class="p">;</span><span class="w"> </span><span class="c1">// with NeXT/Apple systems</span>
</pre></div></li></ul>
<p>An object wishing to implement forwarding needs only to override the forwarding method with a new method to define the forwarding behavior. The action method <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">performv::</code> need not be overridden, as this method merely performs an action based on the selector and arguments. Notice the <code>SEL</code> type, which is the type of messages in Objective-C.
</p><p>Note: in OpenStep, Cocoa, and GNUstep, the commonly used frameworks of Objective-C, one does not use the <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">Object</code> class. The <code class="mw-highlight mw-highlight-lang-objc mw-content-ltr" style="" dir="ltr"><span class="p">-</span> <span class="p">(</span><span class="kt">void</span><span class="p">)</span><span class="nf">forwardInvocation:</span><span class="p">(</span><span class="bp">NSInvocation</span><span class="w"> </span><span class="o">*</span><span class="p">)</span><span class="nv">anInvocation</span></code> method of the <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">NSObject</code> class is used to do forwarding.
</p>
<div class="mw-heading mw-heading4"><h4 id="Example">Example</h4></div>
<p>Here is an example of a program that demonstrates the basics of forwarding.
</p>
<dl><dt><i>Forwarder.h</i></dt></dl>
<div class="mw-highlight mw-highlight-lang-objc mw-content-ltr" dir="ltr"><pre><span class="cp">#import &lt;objc/Object.h&gt;</span>

<span class="k">@interface</span> <span class="nc">Forwarder</span>&nbsp;: <span class="nc">Object</span> <span class="p">{</span>
<span class="w"> </span><span class="kt">id</span><span class="w"> </span><span class="n">recipient</span><span class="p">;</span><span class="w"> </span><span class="c1">// The object we want to forward the message to.</span>
<span class="p">}</span>

<span class="c1">// Accessor methods.</span>
<span class="p">-</span> <span class="p">(</span><span class="kt">id</span><span class="p">)</span><span class="nf">recipient</span><span class="p">;</span>
<span class="p">-</span> <span class="p">(</span><span class="kt">id</span><span class="p">)</span><span class="nf">setRecipient:</span><span class="p">(</span><span class="kt">id</span><span class="p">)</span><span class="nv">_recipient</span><span class="p">;</span>
<span class="k">@end</span>
</pre></div>
<dl><dt><i>Forwarder.m</i></dt></dl>
<div class="mw-highlight mw-highlight-lang-objc mw-content-ltr" dir="ltr"><pre><span class="cp">#import "Forwarder.h"</span>

<span class="k">@implementation</span> <span class="nc">Forwarder</span>
<span class="p">-</span> <span class="p">(</span><span class="n">retval_t</span><span class="p">)</span><span class="nf">forward:</span><span class="p">(</span><span class="kt">SEL</span><span class="p">)</span><span class="nv">sel</span><span class="w"> </span><span class="nf">args:</span><span class="p">(</span><span class="n">arglist_t</span><span class="p">)</span><span class="nv">args</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="cm">/*</span>
<span class="cm"> * Check whether the recipient actually responds to the message.</span>
<span class="cm"> * This may or may not be desirable, for example, if a recipient</span>
<span class="cm"> * in turn does not respond to the message, it might do forwarding</span>
<span class="cm"> * itself.</span>
<span class="cm"> */</span>
<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">([</span><span class="n">recipient</span><span class="w"> </span><span class="n">respondsToSelector</span><span class="o">:</span><span class="n">sel</span><span class="p">])</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="p">[</span><span class="n">recipient</span><span class="w"> </span><span class="n">performv</span><span class="o">:</span><span class="n">sel</span><span class="w"> </span><span class="n">args</span><span class="o">:</span><span class="n">args</span><span class="p">];</span>
<span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="p">[</span><span class="nb">self</span><span class="w"> </span><span class="n">error</span><span class="o">:</span><span class="s">"Recipient does not respond"</span><span class="p">];</span>
<span class="w"> </span><span class="p">}</span>
<span class="p">}</span>

<span class="p">-</span> <span class="p">(</span><span class="kt">id</span><span class="p">)</span><span class="nf">setRecipient:</span><span class="p">(</span><span class="kt">id</span><span class="p">)</span><span class="nv">_recipient</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="p">[</span><span class="n">recipient</span><span class="w"> </span><span class="n">autorelease</span><span class="p">];</span>
<span class="w"> </span><span class="n">recipient</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="n">_recipient</span><span class="w"> </span><span class="k">retain</span><span class="p">];</span>
<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="nb">self</span><span class="p">;</span>
<span class="p">}</span>

<span class="p">-</span> <span class="p">(</span><span class="kt">id</span><span class="p">)</span><span class="nf">recipient</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="n">recipient</span><span class="p">;</span>
<span class="p">}</span>
<span class="k">@end</span>
</pre></div>
<dl><dt><i>Recipient.h</i></dt></dl>
<div class="mw-highlight mw-highlight-lang-objc mw-content-ltr" dir="ltr"><pre><span class="cp">#import &lt;objc/Object.h&gt;</span>

<span class="c1">// A simple Recipient object.</span>
<span class="k">@interface</span> <span class="nc">Recipient</span>&nbsp;: <span class="nc">Object</span>
<span class="p">-</span> <span class="p">(</span><span class="kt">id</span><span class="p">)</span><span class="nf">hello</span><span class="p">;</span>
<span class="k">@end</span>
</pre></div>
<dl><dt><i>Recipient.m</i></dt></dl>
<div class="mw-highlight mw-highlight-lang-objc mw-content-ltr" dir="ltr"><pre><span class="cp">#import "Recipient.h"</span>

<span class="k">@implementation</span> <span class="nc">Recipient</span>

<span class="p">-</span> <span class="p">(</span><span class="kt">id</span><span class="p">)</span><span class="nf">hello</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="n">printf</span><span class="p">(</span><span class="s">"Recipient says hello!</span><span class="se">\n</span><span class="s">"</span><span class="p">);</span>

<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="nb">self</span><span class="p">;</span>
<span class="p">}</span>

<span class="k">@end</span>
</pre></div>
<dl><dt><i>main.m</i></dt></dl>
<div class="mw-highlight mw-highlight-lang-objc mw-content-ltr" dir="ltr"><pre><span class="cp">#import "Forwarder.h"</span>
<span class="cp">#import "Recipient.h"</span>

<span class="kt">int</span><span class="w"> </span><span class="nf">main</span><span class="p">(</span><span class="kt">void</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="n">Forwarder</span><span class="w"> </span><span class="o">*</span><span class="n">forwarder</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="n">Forwarder</span><span class="w"> </span><span class="n">new</span><span class="p">];</span>
<span class="w"> </span><span class="n">Recipient</span><span class="w"> </span><span class="o">*</span><span class="n">recipient</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="n">Recipient</span><span class="w"> </span><span class="n">new</span><span class="p">];</span>

<span class="w"> </span><span class="p">[</span><span class="n">forwarder</span><span class="w"> </span><span class="n">setRecipient</span><span class="o">:</span><span class="n">recipient</span><span class="p">];</span><span class="w"> </span><span class="c1">// Set the recipient.</span>
<span class="w"> </span><span class="cm">/*</span>
<span class="cm"> * Observe forwarder does not respond to a hello message! It will</span>
<span class="cm"> * be forwarded. All unrecognized methods will be forwarded to</span>
<span class="cm"> * the recipient</span>
<span class="cm"> * (if the recipient responds to them, as written in the Forwarder)</span>
<span class="cm"> */</span>
<span class="w"> </span><span class="p">[</span><span class="n">forwarder</span><span class="w"> </span><span class="n">hello</span><span class="p">];</span>

<span class="w"> </span><span class="p">[</span><span class="n">recipient</span><span class="w"> </span><span class="k">release</span><span class="p">];</span>
<span class="w"> </span><span class="p">[</span><span class="n">forwarder</span><span class="w"> </span><span class="k">release</span><span class="p">];</span>

<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="mi">0</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
<div class="mw-heading mw-heading4"><h4 id="Notes">Notes</h4></div>
<p>When compiled using <a href="GNU_Compiler_Collection" title="GNU Compiler Collection">gcc</a>, the compiler reports:
</p>
<div class="mw-highlight mw-highlight-lang-console mw-content-ltr" dir="ltr"><pre><span class="gp">$ </span>gcc<span class="w"> </span>-x<span class="w"> </span>objective-c<span class="w"> </span>-Wno-import<span class="w"> </span>Forwarder.m<span class="w"> </span>Recipient.m<span class="w"> </span>main.m<span class="w"> </span>-lobjc
<span class="go">main.m: In function `main':</span>
<span class="go">main.m:12: warning: `Forwarder' does not respond to `hello'</span>
<span class="gp">$</span>
</pre></div>
<p>The compiler is reporting the point made earlier, that <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">Forwarder</code> does not respond to hello messages. In this circumstance, it is safe to ignore the warning since forwarding was implemented. Running the program produces this output:
</p>
<div class="mw-highlight mw-highlight-lang-console mw-content-ltr" dir="ltr"><pre><span class="gp">$ </span>./a.out
<span class="go">Recipient says hello!</span>
</pre></div>
<div class="mw-heading mw-heading3"><h3 id="Categories">Categories</h3></div>
<p>During the design of Objective-C, one of the main concerns was the maintainability of large code bases. Experience from the <a href="Structured_programming" title="Structured programming">structured programming</a> world had shown that one of the main ways to improve code was to break it down into smaller pieces. Objective-C borrowed and extended the concept of <i>categories</i> from Smalltalk implementations to help with this process.<sup id="cite_ref-26" class="reference"><a href="#cite_note-26"><span class="cite-bracket">[</span>26<span class="cite-bracket">]</span></a></sup>
</p><p>Furthermore, the methods within a category are added to a class at <a href="Run_time_(program_lifecycle_phase)" class="mw-redirect" title="Run time (program lifecycle phase)">run-time</a>. Thus, categories permit the programmer to add methods to an existing class – an <a href="Open_class_(computer_programming)" class="mw-redirect" title="Open class (computer programming)">open class</a> – without the need to recompile that class or even have access to its source code. For example, if a system does not contain a <a href="Spell_checker" title="Spell checker">spell checker</a> in its String implementation, it could be added without modifying the String source code.
</p><p>Methods within categories become indistinguishable from the methods in a class when the program is run. A category has full access to all of the instance variables within the class, including private variables.
</p><p>If a category declares a method with the same <a href="Method_signature" class="mw-redirect" title="Method signature">method signature</a> as an existing method in a class, the category's method is adopted. Thus categories can not only add methods to a class, but also replace existing methods. This feature can be used to fix bugs in other classes by rewriting their methods, or to cause a global change to a class's behavior within a program. If two categories have methods with the same name but different method signatures, it is undefined which category's method is adopted.
</p><p>Other languages have attempted to add this feature in a variety of ways. TOM took the Objective-C system a step further and allowed for the addition of variables also. Other languages have used <a href="Prototype-based_programming" title="Prototype-based programming">prototype-based</a> solutions instead, the most notable being <a href="Self_(programming_language)" title="Self (programming language)">Self</a>.
</p><p>The C# and <a href="Visual_Basic_(.NET)" title="Visual Basic (.NET)">Visual Basic (.NET)</a> languages implement superficially similar function in the form of <a href="Extension_method" title="Extension method">extension methods</a>, but these lack access to the private variables of the class.<sup id="cite_ref-27" class="reference"><a href="#cite_note-27"><span class="cite-bracket">[</span>27<span class="cite-bracket">]</span></a></sup> <a href="Ruby_(programming_language)" title="Ruby (programming language)">Ruby</a> and several other dynamic programming languages refer to the technique as "<a href="Monkey_patch" title="Monkey patch">monkey patching</a>".
</p><p><a href="Logtalk" title="Logtalk">Logtalk</a> implements a concept of categories (as first-class entities) that subsumes Objective-C categories function (Logtalk categories can also be used as fine-grained units of composition when defining e.g. new classes or prototypes; in particular, a Logtalk category can be virtually imported by any number of classes and prototypes).
</p>
<div class="mw-heading mw-heading4"><h4 id="Example_use_of_categories">Example use of categories</h4></div>
<p>This example builds up an <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">Integer</code> class, by defining first a basic class with only <a href="Method_(computer_science)" class="mw-redirect" title="Method (computer science)">accessor methods</a> implemented, and adding two categories, <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">Arithmetic</code> and <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">Display</code>, which extend the basic class. While categories can access the base class's private data members, it is often good practice to access these private data members through the accessor methods, which helps keep categories more independent from the base class. Implementing such accessors is one typical use of categories. Another is to use categories to add methods to the base class. However, it is not regarded as good practice to use categories for subclass overriding, also known as <a href="Monkey_patch" title="Monkey patch">monkey patching</a>. Informal protocols are implemented as a category on the base <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">NSObject</code> class. By convention, files containing categories that extend base classes will take the name <u>BaseClass+ExtensionClass.h</u>.
</p>
<dl><dt><i>Integer.h</i></dt>
<dd><div class="mw-highlight mw-highlight-lang-objc mw-content-ltr" dir="ltr"><pre><span class="cp">#import &lt;objc/Object.h&gt;</span>

<span class="k">@interface</span> <span class="nc">Integer</span>&nbsp;: <span class="nc">Object</span> <span class="p">{</span>
<span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">integer</span><span class="p">;</span>
<span class="p">}</span>

<span class="p">-</span> <span class="p">(</span><span class="kt">int</span><span class="p">)</span><span class="nf">integer</span><span class="p">;</span>
<span class="p">-</span> <span class="p">(</span><span class="kt">id</span><span class="p">)</span><span class="nf">integer:</span><span class="p">(</span><span class="kt">int</span><span class="p">)</span><span class="nv">_integer</span><span class="p">;</span>
<span class="k">@end</span>
</pre></div></dd></dl>
<dl><dt><i>Integer.m</i></dt>
<dd><div class="mw-highlight mw-highlight-lang-objc mw-content-ltr" dir="ltr"><pre><span class="cp">#import "Integer.h"</span>

<span class="k">@implementation</span> <span class="nc">Integer</span>
<span class="p">-</span> <span class="p">(</span><span class="kt">int</span><span class="p">)</span> <span class="nf">integer</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="n">integer</span><span class="p">;</span>
<span class="p">}</span>

<span class="p">-</span> <span class="p">(</span><span class="kt">id</span><span class="p">)</span> <span class="nf">integer:</span><span class="w"> </span><span class="p">(</span><span class="kt">int</span><span class="p">)</span> <span class="nv">_integer</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="n">integer</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">_integer</span><span class="p">;</span>
<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="nb">self</span><span class="p">;</span>
<span class="p">}</span>
<span class="k">@end</span>
</pre></div></dd></dl>
<dl><dt><i>Integer+Arithmetic.h</i></dt>
<dd><div class="mw-highlight mw-highlight-lang-objc mw-content-ltr" dir="ltr"><pre><span class="cp">#import "Integer.h"</span>

<span class="k">@interface</span> <span class="nc">Integer</span> <span class="nl">(Arithmetic)</span>
<span class="p">-</span> <span class="p">(</span><span class="kt">id</span><span class="p">)</span> <span class="nf">add:</span><span class="w"> </span><span class="p">(</span><span class="n">Integer</span><span class="w"> </span><span class="o">*</span><span class="p">)</span> <span class="nv">addend</span><span class="p">;</span>
<span class="p">-</span> <span class="p">(</span><span class="kt">id</span><span class="p">)</span> <span class="nf">sub:</span><span class="w"> </span><span class="p">(</span><span class="n">Integer</span><span class="w"> </span><span class="o">*</span><span class="p">)</span> <span class="nv">subtrahend</span><span class="p">;</span>
<span class="k">@end</span>
</pre></div></dd></dl>
<dl><dt><i>Integer+Arithmetic.m</i></dt>
<dd><div class="mw-highlight mw-highlight-lang-objc mw-content-ltr" dir="ltr"><pre><span class="cp">#import "Integer+Arithmetic.h"</span>

<span class="k">@implementation</span> <span class="nc">Integer</span> <span class="nl">(Arithmetic)</span>
<span class="p">-</span> <span class="p">(</span><span class="kt">id</span><span class="p">)</span> <span class="nf">add:</span><span class="w"> </span><span class="p">(</span><span class="n">Integer</span><span class="w"> </span><span class="o">*</span><span class="p">)</span> <span class="nv">addend</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="p">[</span><span class="nb">self</span><span class="w"> </span><span class="n">integer</span><span class="o">:</span><span class="w"> </span><span class="p">[</span><span class="nb">self</span><span class="w"> </span><span class="n">integer</span><span class="p">]</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="p">[</span><span class="n">addend</span><span class="w"> </span><span class="n">integer</span><span class="p">]];</span>
<span class="p">}</span>

<span class="p">-</span> <span class="p">(</span><span class="kt">id</span><span class="p">)</span> <span class="nf">sub:</span><span class="w"> </span><span class="p">(</span><span class="n">Integer</span><span class="w"> </span><span class="o">*</span><span class="p">)</span> <span class="nv">subtrahend</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="p">[</span><span class="nb">self</span><span class="w"> </span><span class="n">integer</span><span class="o">:</span><span class="w"> </span><span class="p">[</span><span class="nb">self</span><span class="w"> </span><span class="n">integer</span><span class="p">]</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="p">[</span><span class="n">subtrahend</span><span class="w"> </span><span class="n">integer</span><span class="p">]];</span>
<span class="p">}</span>
<span class="k">@end</span>
</pre></div></dd></dl>
<dl><dt><i>Integer+Display.h</i></dt>
<dd><div class="mw-highlight mw-highlight-lang-objc mw-content-ltr" dir="ltr"><pre><span class="cp">#import "Integer.h"</span>

<span class="k">@interface</span> <span class="nc">Integer</span> <span class="nl">(Display)</span>
<span class="p">-</span> <span class="p">(</span><span class="kt">id</span><span class="p">)</span> <span class="nf">showstars</span><span class="p">;</span>
<span class="p">-</span> <span class="p">(</span><span class="kt">id</span><span class="p">)</span> <span class="nf">showint</span><span class="p">;</span>
<span class="k">@end</span>
</pre></div></dd></dl>
<dl><dt><i>Integer+Display.m</i></dt>
<dd><div class="mw-highlight mw-highlight-lang-objc mw-content-ltr" dir="ltr"><pre><span class="cp"># import "Integer+Display.h"</span>

<span class="k">@implementation</span> <span class="nc">Integer</span> <span class="nl">(Display)</span>
<span class="p">-</span> <span class="p">(</span><span class="kt">id</span><span class="p">)</span> <span class="nf">showstars</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">i</span><span class="p">,</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="nb">self</span><span class="w"> </span><span class="n">integer</span><span class="p">];</span>
<span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="n">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span><span class="p">;</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">&lt;</span><span class="w"> </span><span class="n">x</span><span class="p">;</span><span class="w"> </span><span class="n">i</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="n">printf</span><span class="p">(</span><span class="s">"*"</span><span class="p">);</span>
<span class="w"> </span><span class="p">}</span>
<span class="w"> </span><span class="n">printf</span><span class="p">(</span><span class="s">"</span><span class="se">\n</span><span class="s">"</span><span class="p">);</span>

<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="nb">self</span><span class="p">;</span>
<span class="p">}</span>

<span class="p">-</span> <span class="p">(</span><span class="kt">id</span><span class="p">)</span> <span class="nf">showint</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="n">printf</span><span class="p">(</span><span class="s">"%d</span><span class="se">\n</span><span class="s">"</span><span class="p">,</span><span class="w"> </span><span class="p">[</span><span class="nb">self</span><span class="w"> </span><span class="n">integer</span><span class="p">]);</span>

<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="nb">self</span><span class="p">;</span>
<span class="p">}</span>
<span class="k">@end</span>
</pre></div></dd></dl>
<dl><dt><i>main.m</i></dt>
<dd><div class="mw-highlight mw-highlight-lang-objc mw-content-ltr mw-highlight-lines" dir="ltr"><pre><span class="cp">#import "Integer.h"</span>
<span class="cp">#import "Integer+Arithmetic.h"</span>
<span class="cp">#import "Integer+Display.h"</span>

<span class="kt">int</span><span class="w"> </span><span class="nf">main</span><span class="p">(</span><span class="kt">void</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="n">Integer</span><span class="w"> </span><span class="o">*</span><span class="n">num1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="n">Integer</span><span class="w"> </span><span class="n">new</span><span class="p">],</span><span class="w"> </span><span class="o">*</span><span class="n">num2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="n">Integer</span><span class="w"> </span><span class="n">new</span><span class="p">];</span>
<span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">x</span><span class="p">;</span>

<span class="w"> </span><span class="n">printf</span><span class="p">(</span><span class="s">"Enter an integer: "</span><span class="p">);</span>
<span class="w"> </span><span class="n">scanf</span><span class="p">(</span><span class="s">"%d"</span><span class="p">,</span><span class="w"> </span><span class="o">&amp;</span><span class="n">x</span><span class="p">);</span>

<span class="w"> </span><span class="p">[</span><span class="n">num1</span><span class="w"> </span><span class="n">integer</span><span class="o">:</span><span class="n">x</span><span class="p">];</span>
<span class="w"> </span><span class="p">[</span><span class="n">num1</span><span class="w"> </span><span class="n">showstars</span><span class="p">];</span>

<span class="w"> </span><span class="n">printf</span><span class="p">(</span><span class="s">"Enter an integer: "</span><span class="p">);</span>
<span class="w"> </span><span class="n">scanf</span><span class="p">(</span><span class="s">"%d"</span><span class="p">,</span><span class="w"> </span><span class="o">&amp;</span><span class="n">x</span><span class="p">);</span>

<span class="w"> </span><span class="p">[</span><span class="n">num2</span><span class="w"> </span><span class="n">integer</span><span class="o">:</span><span class="n">x</span><span class="p">];</span>
<span class="w"> </span><span class="p">[</span><span class="n">num2</span><span class="w"> </span><span class="n">showstars</span><span class="p">];</span>

<span class="w"> </span><span class="p">[</span><span class="n">num1</span><span class="w"> </span><span class="n">add</span><span class="o">:</span><span class="n">num2</span><span class="p">];</span>
<span class="w"> </span><span class="p">[</span><span class="n">num1</span><span class="w"> </span><span class="n">showint</span><span class="p">];</span>

<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="mi">0</span><span class="p">;</span>
<span class="p">}</span>
</pre></div></dd></dl>
<div class="mw-heading mw-heading4"><h4 id="Notes_2">Notes</h4></div>
<p>Compilation is performed, for example, by:
</p>
<div class="mw-highlight mw-highlight-lang-console mw-content-ltr" dir="ltr"><pre><span class="gp">$ </span>gcc<span class="w"> </span>-x<span class="w"> </span>objective-c<span class="w"> </span>main.m<span class="w"> </span>Integer.m<span class="w"> </span>Integer+Arithmetic.m<span class="w"> </span>Integer+Display.m<span class="w"> </span>-lobjc
</pre></div>
<p>One can experiment by leaving out the <code class="mw-highlight mw-highlight-lang-objc mw-content-ltr" style="" dir="ltr"><span class="cp">#import "Integer+Arithmetic.h"</span></code> (line 2) and <code class="mw-highlight mw-highlight-lang-objc mw-content-ltr" style="" dir="ltr"><span class="p">[</span><span class="n">num1</span><span class="w"> </span><span class="n">add</span><span class="o">:</span><span class="n">num2</span><span class="p">]</span></code> (line 21) and omitting <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">Integer+Arithmetic.m</code> in compilation. The program will still run. This means that it is possible to <i>mix-and-match</i> added categories if needed; if a category does not need to have some ability, it can simply not be compiled in.
</p>
<div class="mw-heading mw-heading3"><h3 id="Posing">Posing</h3></div>
<p>Objective-C permits a class to wholly replace another class within a program. The replacing class is said to "pose as" the target class.
</p><p>Class posing was declared deprecated with <a href="Mac_OS_X_v10.5" class="mw-redirect" title="Mac OS X v10.5">Mac OS X v10.5</a>, and is unavailable in the <a href="64-bit_computing" title="64-bit computing">64-bit</a> runtime. Similar function can be achieved by using method swizzling in categories, that swaps one method's implementation with another's that have the same signature.
</p><p>For the versions still supporting posing, all messages sent to the target class are instead received by the posing class. There are several restrictions:
</p>
<ul><li>A class may only pose as one of its direct or indirect superclasses.</li>
<li>The posing class must not define any new instance variables that are absent from the target class (though it may define or override methods).</li>
<li>The target class may not have received any messages prior to the posing.</li></ul>
<p>Posing, similarly with categories, allows global augmentation of existing classes. Posing permits two features absent from categories:
</p>
<ul><li>A posing class can call overridden methods through super, thus incorporating the implementation of the target class.</li>
<li>A posing class can override methods defined in categories.</li></ul>
<p>For example,
</p>
<div class="mw-highlight mw-highlight-lang-objc mw-content-ltr" dir="ltr"><pre><span class="k">@interface</span> <span class="nc">CustomNSApplication</span>&nbsp;: <span class="nc">NSApplication</span>
<span class="k">@end</span>

<span class="k">@implementation</span> <span class="nc">CustomNSApplication</span>
<span class="p">-</span> <span class="p">(</span><span class="kt">void</span><span class="p">)</span> <span class="nf">setMainMenu:</span><span class="w"> </span><span class="p">(</span><span class="n">NSMenu</span><span class="o">*</span><span class="p">)</span> <span class="nv">menu</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="c1">// do something with menu</span>
<span class="p">}</span>
<span class="k">@end</span>

<span class="n">class_poseAs</span><span class="w"> </span><span class="p">([</span><span class="n">CustomNSApplication</span><span class="w"> </span><span class="k">class</span><span class="p">],</span><span class="w"> </span><span class="p">[</span><span class="n">NSApplication</span><span class="w"> </span><span class="k">class</span><span class="p">]);</span>
</pre></div>
<p>This intercepts every invocation of setMainMenu to NSApplication.
</p>
<div class="mw-heading mw-heading3"><h3 id="#import">#import</h3></div>
<p>In the C language, the <code>#include</code> pre-compile directive always causes a file's contents to be inserted into the source at that point. Objective-C has the <code>#import</code> directive, equivalent except that each file is included only once per compilation unit, obviating the need for <a href="Include_guard" title="Include guard">include guards</a>.
</p><p>The Objective-C directive should not be confused with the <a href="C%2B%2B" title="C++">C++</a> keyword <code>import</code>, which is used to import C++ <a href="Modules_(C%2B%2B)" title="Modules (C++)">modules</a> (since <a href="C%2B%2B20" title="C++20">C++20</a>), and is not a preprocessor directive. It should also not be confused with the <code>#import</code> preprocessor directive in <a href="Microsoft_Visual_C%2B%2B" title="Microsoft Visual C++">Microsoft Visual C++</a> (MSVC), which is non-standard and used to import type libraries.<sup id="cite_ref-28" class="reference"><a href="#cite_note-28"><span class="cite-bracket">[</span>28<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading3"><h3 id="Linux_gcc_compilation">Linux gcc compilation</h3></div>
<div class="mw-highlight mw-highlight-lang-objc mw-content-ltr" dir="ltr"><pre><span class="c1">// FILE: hello.m</span>
<span class="cp">#import &lt;Foundation/Foundation.h&gt;</span>
<span class="kt">int</span><span class="w"> </span><span class="nf">main</span><span class="w"> </span><span class="p">(</span><span class="kt">int</span><span class="w"> </span><span class="n">argc</span><span class="p">,</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="kt">char</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="n">argv</span><span class="p">[])</span>
<span class="p">{</span>
<span class="w"> </span><span class="cm">/* my first program in Objective-C */</span>
<span class="w"> </span><span class="n">NSLog</span><span class="p">(</span><span class="s">@"Hello, World! </span><span class="se">\n</span><span class="s">"</span><span class="p">);</span>
<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="mi">0</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
<div class="mw-highlight mw-highlight-lang-shell-session mw-content-ltr" dir="ltr"><pre><span class="gp">$ </span><span class="c1"># Compile Command Line for gcc and MinGW Compiler:</span>
<span class="gp">$ </span>gcc<span class="w"> </span><span class="se">\</span>
<span class="gp"> $</span><span class="o">(</span>gnustep-config<span class="w"> </span>--objc-flags<span class="o">)</span><span class="w"> </span><span class="se">\</span>
<span class="w"> </span>-o<span class="w"> </span>hello<span class="w"> </span><span class="se">\</span>
<span class="w"> </span>hello.m<span class="w"> </span><span class="se">\</span>
<span class="w"> </span>-L<span class="w"> </span>/GNUstep/System/Library/Libraries<span class="w"> </span><span class="se">\</span>
<span class="w"> </span>-lobjc<span class="w"> </span><span class="se">\</span>
<span class="w"> </span>-lgnustep-base

<span class="gp">$ </span>./hello
</pre></div>
<div class="mw-heading mw-heading2"><h2 id="Other_features">Other features</h2></div>
<p>Objective-C's features often allow for flexible, and often easy, solutions to programming issues.
</p>
<ul><li>Delegating methods to other objects and <a href="Remote_procedure_call" title="Remote procedure call">remote invocation</a> can be easily implemented using categories and message forwarding.</li>
<li><a href="Pointer_swizzling" title="Pointer swizzling">Swizzling</a> of the <var>isa</var> pointer allows for classes to change at runtime. Typically used for <a href="Debugging" title="Debugging">debugging</a> where freed objects are swizzled into zombie objects whose only purpose is to report an error when someone calls them. Swizzling was also used in <a href="Enterprise_Objects_Framework" title="Enterprise Objects Framework">Enterprise Objects Framework</a> to create database faults. Swizzling is used today by Apple's Foundation Framework to implement Key-Value Observing.</li></ul>
<div class="mw-heading mw-heading2"><h2 id="Language_variants">Language variants</h2></div>
<div class="mw-heading mw-heading3"><h3 id="Objective-C++">Objective-C++</h3></div>
<p>Objective-C++ is a language variant accepted by the front-end to the <a href="GNU_Compiler_Collection" title="GNU Compiler Collection">GNU Compiler Collection</a> and <a href="Clang" title="Clang">Clang</a>, which can compile source files that use a combination of <a href="C%2B%2B" title="C++">C++</a> and Objective-C syntax. The term "Objective-C++" was once featured in the <a href="Apple_Inc." title="Apple Inc.">Apple</a> Documentation for their Objective-C compiler as well, but has since been removed.<sup id="cite_ref-29" class="reference"><a href="#cite_note-29"><span class="cite-bracket">[</span>29<span class="cite-bracket">]</span></a></sup>
</p><p>Objective-C++ adds to C++ the extensions that Objective-C adds to <a href="C_(Programming_Language)" class="mw-redirect" title="C (Programming Language)">C</a>. As nothing is done to unify the semantics behind the various language features, certain restrictions apply:
</p>
<ul><li>A C++ <a href="Class_(computer_programming)" title="Class (computer programming)">class</a> cannot <a href="Inheritance_(object-oriented_programming)" title="Inheritance (object-oriented programming)">derive</a> from an Objective-C class and vice versa.</li>
<li>C++ <a href="Namespace" title="Namespace">namespaces</a> cannot be declared inside an Objective-C declaration.</li>
<li>Objective-C declarations may appear only in global scope, not inside a C++ namespace.</li>
<li>Objective-C classes cannot have instance variables of C++ classes that lack a <a href="Default_constructor" title="Default constructor">default constructor</a> or that have one or more <a href="Virtual_method" class="mw-redirect" title="Virtual method">virtual methods</a>, but <a href="Pointer_(computer_programming)" title="Pointer (computer programming)">pointers</a> to C++ objects can be used as instance variables without restriction (allocate them with new in the -init method).</li>
<li>C++ "by value" semantics cannot be applied to Objective-C objects, which are only accessible through pointers.</li>
<li>An Objective-C declaration cannot be within a <a href="Template_(C%2B%2B)" title="Template (C++)">C++ template</a> declaration and vice versa. However, Objective-C types (e.g., <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">Classname *</code>) can be used as C++ template parameters.</li>
<li>Objective-C and C++ <a href="Exception_handling_(programming)" title="Exception handling (programming)">exception handling</a> are distinct; the handlers of each cannot handle exceptions of the other type. As a result, object destructors are not run. This is mitigated in recent "Objective-C 2.0" <a href="Runtime_system" title="Runtime system">runtimes</a> as Objective-C exceptions are either replaced by C++ exceptions completely (Apple runtime), or partly when Objective-C++ library is linked (<a href="GNUStep" class="mw-redirect" title="GNUStep">GNUStep</a> libobjc2).<sup id="cite_ref-30" class="reference"><a href="#cite_note-30"><span class="cite-bracket">[</span>30<span class="cite-bracket">]</span></a></sup></li>
<li>Objective-C blocks and C++11 <a href="Anonymous_function#C++_(since_C++11)" title="Anonymous function">lambdas</a> are distinct entities. However, a block is transparently generated on macOS when passing a lambda where a block is expected.<sup id="cite_ref-31" class="reference"><a href="#cite_note-31"><span class="cite-bracket">[</span>31<span class="cite-bracket">]</span></a></sup></li></ul>
<div class="mw-heading mw-heading3"><h3 id="Objective-C_2.0">Objective-C 2.0</h3></div>
<p>At the 2006 <a href="Worldwide_Developers_Conference" title="Worldwide Developers Conference">Worldwide Developers Conference</a>, Apple announced the release of "Objective-C 2.0," a revision of the Objective-C language to include "modern garbage collection, syntax enhancements,<sup id="cite_ref-32" class="reference"><a href="#cite_note-32"><span class="cite-bracket">[</span>32<span class="cite-bracket">]</span></a></sup> runtime performance improvements,<sup id="cite_ref-33" class="reference"><a href="#cite_note-33"><span class="cite-bracket">[</span>33<span class="cite-bracket">]</span></a></sup> and 64-bit support". <a href="Mac_OS_X_v10.5" class="mw-redirect" title="Mac OS X v10.5">Mac OS X v10.5</a>, released in October 2007, included an Objective-C 2.0 compiler. <a href="GNU_Compiler_Collection" title="GNU Compiler Collection">GCC 4.6</a> supports many new Objective-C features, such as declared and synthesized properties, dot syntax, fast enumeration, optional protocol methods, method/protocol/class attributes, class extensions, and a new GNU Objective-C runtime API.<sup id="cite_ref-gcc46_34-0" class="reference"><a href="#cite_note-gcc46-34"><span class="cite-bracket">[</span>34<span class="cite-bracket">]</span></a></sup>
</p><p>The naming Objective-C 2.0 represents a break in the versioning system of the language, as the last Objective-C version for NeXT was "objc4".<sup id="cite_ref-objc2-faq_35-0" class="reference"><a href="#cite_note-objc2-faq-35"><span class="cite-bracket">[</span>35<span class="cite-bracket">]</span></a></sup> This project name was kept in the last release of legacy Objective-C runtime source code in <a href="Mac_OS_X_Leopard" title="Mac OS X Leopard">Mac OS X Leopard</a> (10.5).<sup id="cite_ref-36" class="reference"><a href="#cite_note-36"><span class="cite-bracket">[</span>36<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading4"><h4 id="Garbage_collection">Garbage collection</h4></div>
<p>Objective-C 2.0 provided an optional conservative, generational <a href="Garbage_collection_(computer_science)" title="Garbage collection (computer science)">garbage collector</a>. When run in <a href="Backwards-compatible" class="mw-redirect" title="Backwards-compatible">backwards-compatible</a> mode, the runtime turned <a href="Reference_counting" title="Reference counting">reference counting</a> operations such as "retain" and "release" into <a href="No-op" class="mw-redirect" title="No-op">no-ops</a>. All objects were subject to garbage collection when garbage collection was enabled. Regular C pointers could be qualified with "__strong" to also trigger the underlying write-barrier compiler intercepts and thus participate in garbage collection.<sup id="cite_ref-37" class="reference"><a href="#cite_note-37"><span class="cite-bracket">[</span>37<span class="cite-bracket">]</span></a></sup> A zero-ing weak subsystem was also provided such that pointers marked as "__weak" are set to zero when the object (or more simply, GC memory) is collected. The garbage collector does not exist on the iOS implementation of Objective-C 2.0.<sup id="cite_ref-38" class="reference"><a href="#cite_note-38"><span class="cite-bracket">[</span>38<span class="cite-bracket">]</span></a></sup> Garbage collection in Objective-C runs on a low-priority background thread, and can halt on user events, with the intention of keeping the user experience responsive.<sup id="cite_ref-39" class="reference"><a href="#cite_note-39"><span class="cite-bracket">[</span>39<span class="cite-bracket">]</span></a></sup>
</p><p>Garbage collection was deprecated in Mac OS X v10.8 in favor of <a href="Automatic_Reference_Counting" title="Automatic Reference Counting">Automatic Reference Counting</a> (ARC).<sup id="cite_ref-40" class="reference"><a href="#cite_note-40"><span class="cite-bracket">[</span>40<span class="cite-bracket">]</span></a></sup> Objective-C on <a href="IOS_7" title="IOS 7">iOS 7</a> running on <a href="ARM64" class="mw-redirect" title="ARM64">ARM64</a> uses 19 bits out of a 64-bit word to store the reference count, as a form of <a href="Tagged_pointer" title="Tagged pointer">tagged pointers</a>.<sup id="cite_ref-41" class="reference"><a href="#cite_note-41"><span class="cite-bracket">[</span>41<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-42" class="reference"><a href="#cite_note-42"><span class="cite-bracket">[</span>42<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading4"><h4 id="Properties">Properties</h4></div>
<p>Objective-C 2.0 introduces a new syntax to declare instance variables as <a href="Property_(programming)" title="Property (programming)">properties</a>, with optional attributes to configure the generation of accessor methods. Properties are, in a sense, public instance variables; that is, declaring an instance variable as a property provides external classes with access (possibly limited, e.g. read only) to that property. A property may be declared as "readonly", and may be provided with storage semantics such as <code>assign</code>, <code>copy</code> or <code>retain</code>. By default, properties are considered <code>atomic</code>, which results in a lock preventing multiple threads from accessing them at the same time. A property can be declared as <code>nonatomic</code>, which removes this lock.
</p>
<div class="mw-highlight mw-highlight-lang-objc mw-content-ltr" dir="ltr"><pre><span class="k">@interface</span> <span class="nc">Person</span>&nbsp;: <span class="bp">NSObject</span> <span class="p">{</span>
<span class="k">@public</span>
<span class="w"> </span><span class="bp">NSString</span><span class="w"> </span><span class="o">*</span><span class="n">name</span><span class="p">;</span>
<span class="k">@private</span>
<span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">age</span><span class="p">;</span>
<span class="p">}</span>

<span class="k">@property</span><span class="p">(</span><span class="k">copy</span><span class="p">)</span><span class="w"> </span><span class="bp">NSString</span><span class="w"> </span><span class="o">*</span><span class="n">name</span><span class="p">;</span>
<span class="k">@property</span><span class="p">(</span><span class="k">readonly</span><span class="p">)</span><span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">age</span><span class="p">;</span>

<span class="p">-</span> <span class="p">(</span><span class="kt">id</span><span class="p">)</span><span class="nf">initWithAge:</span><span class="p">(</span><span class="kt">int</span><span class="p">)</span><span class="nv">age</span><span class="p">;</span>
<span class="k">@end</span>
</pre></div>
<p>Properties are implemented by way of the <code>@synthesize</code> keyword, which generates getter (and setter, if not read-only) methods according to the property declaration. Alternatively, the getter and setter methods must be implemented explicitly, or the <code>@dynamic</code> keyword can be used to indicate that accessor methods will be provided by other means. When compiled using clang 3.1 or higher, all properties which are not explicitly declared with <code>@dynamic</code>, marked <code>readonly</code> or have complete user-implemented getter and setter will be automatically implicitly <code>@synthesize</code>'d.
</p>
<div class="mw-highlight mw-highlight-lang-objc mw-content-ltr" dir="ltr"><pre><span class="k">@implementation</span> <span class="nc">Person</span>
<span class="k">@synthesize</span><span class="w"> </span><span class="n">name</span><span class="p">;</span>

<span class="p">-</span> <span class="p">(</span><span class="kt">id</span><span class="p">)</span><span class="nf">initWithAge:</span><span class="p">(</span><span class="kt">int</span><span class="p">)</span><span class="nv">initAge</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="nb">self</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="nb">super</span><span class="w"> </span><span class="n">init</span><span class="p">];</span>
<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nb">self</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="c1">// NOTE: direct instance variable assignment, not property setter</span>
<span class="w"> </span><span class="n">age</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">initAge</span><span class="p">;</span>
<span class="w"> </span><span class="p">}</span>
<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="nb">self</span><span class="p">;</span>
<span class="p">}</span>

<span class="p">-</span> <span class="p">(</span><span class="kt">int</span><span class="p">)</span><span class="nf">age</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="n">age</span><span class="p">;</span>
<span class="p">}</span>
<span class="k">@end</span>
</pre></div>
<p>Properties can be accessed using the traditional message passing syntax, dot notation, or, in Key-Value Coding, by name via the "valueForKey:"/"setValue:forKey:" methods.
</p>
<div class="mw-highlight mw-highlight-lang-objc mw-content-ltr" dir="ltr"><pre><span class="n">Person</span><span class="w"> </span><span class="o">*</span><span class="n">aPerson</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[[</span><span class="n">Person</span><span class="w"> </span><span class="n">alloc</span><span class="p">]</span><span class="w"> </span><span class="n">initWithAge</span><span class="o">:</span><span class="mi">53</span><span class="p">];</span>
<span class="n">aPerson</span><span class="p">.</span><span class="n">name</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">@"Steve"</span><span class="p">;</span><span class="w"> </span><span class="c1">// NOTE: dot notation, uses synthesized setter,</span>
<span class="w"> </span><span class="c1">// equivalent to [aPerson setName: @"Steve"];</span>
<span class="n">NSLog</span><span class="p">(</span><span class="s">@"Access by message (%@), dot notation(%@), property name(% @) and "</span>
<span class="w"> </span><span class="s">"direct instance variable access(% @) "</span><span class="p">,</span>
<span class="w"> </span><span class="p">[</span><span class="n">aPerson</span><span class="w"> </span><span class="n">name</span><span class="p">],</span>
<span class="w"> </span><span class="n">aPerson</span><span class="p">.</span><span class="n">name</span><span class="p">,</span><span class="w"> </span><span class="p">[</span><span class="n">aPerson</span><span class="w"> </span><span class="n">valueForKey</span><span class="o">:</span><span class="s">@"name"</span><span class="p">],</span><span class="w"> </span><span class="n">aPerson</span><span class="w"> </span><span class="o">-&gt;</span><span class="w"> </span><span class="n">name</span><span class="p">);</span>
</pre></div>
<p>To use dot notation to invoke property accessors within an instance method, the <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">self</code> keyword should be used:
</p>
<div class="mw-highlight mw-highlight-lang-objc mw-content-ltr" dir="ltr"><pre><span class="p">-</span> <span class="p">(</span><span class="kt">void</span><span class="p">)</span><span class="nf">introduceMyselfWithProperties:</span><span class="p">(</span><span class="kt">BOOL</span><span class="p">)</span><span class="nv">useGetter</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="n">NSLog</span><span class="p">(</span><span class="s">@"Hi, my name is&nbsp;%@."</span><span class="p">,</span><span class="w"> </span><span class="p">(</span><span class="n">useGetter</span><span class="w"> </span><span class="o">?</span><span class="w"> </span><span class="nb">self</span><span class="p">.</span><span class="n">name</span><span class="w"> </span><span class="o">:</span><span class="w"> </span><span class="n">name</span><span class="p">));</span>
<span class="w"> </span><span class="c1">// NOTE: getter vs. ivar access</span>
<span class="p">}</span>
</pre></div>
<p>A class or protocol's properties may be dynamically <a href="Type_introspection" title="Type introspection">introspected</a>.
</p>
<div class="mw-highlight mw-highlight-lang-objc mw-content-ltr" dir="ltr"><pre><span class="kt">int</span><span class="w"> </span><span class="n">i</span><span class="p">;</span>
<span class="kt">int</span><span class="w"> </span><span class="n">propertyCount</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span><span class="p">;</span>
<span class="n">objc_property_t</span><span class="w"> </span><span class="o">*</span><span class="n">propertyList</span><span class="w"> </span><span class="o">=</span>
<span class="w"> </span><span class="n">class_copyPropertyList</span><span class="p">([</span><span class="n">aPerson</span><span class="w"> </span><span class="k">class</span><span class="p">],</span><span class="w"> </span><span class="o">&amp;</span><span class="n">propertyCount</span><span class="p">);</span>

<span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="n">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span><span class="p">;</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">&lt;</span><span class="w"> </span><span class="n">propertyCount</span><span class="p">;</span><span class="w"> </span><span class="n">i</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="n">objc_property_t</span><span class="w"> </span><span class="o">*</span><span class="n">thisProperty</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">propertyList</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">i</span><span class="p">;</span>
<span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="kt">char</span><span class="w"> </span><span class="o">*</span><span class="n">propertyName</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">property_getName</span><span class="p">(</span><span class="o">*</span><span class="n">thisProperty</span><span class="p">);</span>
<span class="w"> </span><span class="n">NSLog</span><span class="p">(</span><span class="s">@"Person has a property: '%s'"</span><span class="p">,</span><span class="w"> </span><span class="n">propertyName</span><span class="p">);</span>
<span class="p">}</span>
</pre></div>
<div class="mw-heading mw-heading4"><h4 id="Non-fragile_instance_variables">Non-fragile instance variables</h4></div>
<p>Objective-C 2.0 provides non-fragile instance variables where supported by the runtime (i.e. when building code for 64-bit macOS, and all iOS). Under the modern runtime, an extra layer of indirection is added to instance variable access, allowing the dynamic linker to adjust instance layout at runtime. This feature allows for two important improvements to Objective-C code:
</p>
<ul><li>It eliminates the <a href="Fragile_binary_interface_problem" title="Fragile binary interface problem">fragile binary interface problem</a>; superclasses can change sizes without affecting binary compatibility.</li>
<li>It allows instance variables that provide the backing for properties to be synthesized at runtime without them being declared in the class's interface.</li></ul>
<div class="mw-heading mw-heading4"><h4 id="Fast_enumeration">Fast enumeration</h4></div>
<p>Instead of using an NSEnumerator object or indices to iterate through a collection, Objective-C 2.0 offers the fast enumeration syntax. In Objective-C 2.0, the following loops are functionally equivalent, but have different performance traits.
</p>
<div class="mw-highlight mw-highlight-lang-objc mw-content-ltr" dir="ltr"><pre><span class="c1">// Using NSEnumerator</span>
<span class="bp">NSEnumerator</span><span class="w"> </span><span class="o">*</span><span class="n">enumerator</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="n">thePeople</span><span class="w"> </span><span class="n">objectEnumerator</span><span class="p">];</span>
<span class="n">Person</span><span class="w"> </span><span class="o">*</span><span class="n">p</span><span class="p">;</span>

<span class="k">while</span><span class="w"> </span><span class="p">((</span><span class="n">p</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="n">enumerator</span><span class="w"> </span><span class="n">nextObject</span><span class="p">])</span><span class="w"> </span><span class="o">!=</span><span class="w"> </span><span class="nb">nil</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="n">NSLog</span><span class="p">(</span><span class="s">@"%@ is %i years old."</span><span class="p">,</span><span class="w"> </span><span class="p">[</span><span class="n">p</span><span class="w"> </span><span class="n">name</span><span class="p">],</span><span class="w"> </span><span class="p">[</span><span class="n">p</span><span class="w"> </span><span class="n">age</span><span class="p">]);</span>
<span class="p">}</span>
</pre></div>
<div class="mw-highlight mw-highlight-lang-objc mw-content-ltr" dir="ltr"><pre><span class="c1">// Using indexes</span>
<span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="kt">int</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span><span class="p">;</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">&lt;</span><span class="w"> </span><span class="p">[</span><span class="n">thePeople</span><span class="w"> </span><span class="n">count</span><span class="p">];</span><span class="w"> </span><span class="n">i</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="n">Person</span><span class="w"> </span><span class="o">*</span><span class="n">p</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="n">thePeople</span><span class="w"> </span><span class="n">objectAtIndex</span><span class="o">:</span><span class="n">i</span><span class="p">];</span>
<span class="w"> </span><span class="n">NSLog</span><span class="p">(</span><span class="s">@"%@ is %i years old."</span><span class="p">,</span><span class="w"> </span><span class="p">[</span><span class="n">p</span><span class="w"> </span><span class="n">name</span><span class="p">],</span><span class="w"> </span><span class="p">[</span><span class="n">p</span><span class="w"> </span><span class="n">age</span><span class="p">]);</span>
<span class="p">}</span>
</pre></div>
<div class="mw-highlight mw-highlight-lang-objc mw-content-ltr" dir="ltr"><pre><span class="c1">// Using fast enumeration</span>
<span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="n">Person</span><span class="w"> </span><span class="o">*</span><span class="n">p</span><span class="w"> </span><span class="k">in</span><span class="w"> </span><span class="n">thePeople</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="n">NSLog</span><span class="p">(</span><span class="s">@"%@ is %i years old."</span><span class="p">,</span><span class="w"> </span><span class="p">[</span><span class="n">p</span><span class="w"> </span><span class="n">name</span><span class="p">],</span><span class="w"> </span><span class="p">[</span><span class="n">p</span><span class="w"> </span><span class="n">age</span><span class="p">]);</span>
<span class="p">}</span>
</pre></div>
<p>Fast enumeration generates more efficient code than standard enumeration because method calls to enumerate over objects are replaced by pointer arithmetic using the NSFastEnumeration protocol.<sup id="cite_ref-43" class="reference"><a href="#cite_note-43"><span class="cite-bracket">[</span>43<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading4"><h4 id="Class_extensions">Class extensions</h4></div>
<p>A class extension has the same syntax as a category declaration with no category name, and the methods and properties declared in it are added directly to the main class. It is mostly used as an alternative to a category to add methods to a class without advertising them in the public headers, with the advantage that for class extensions the compiler checks that all the privately declared methods are actually implemented.<sup id="cite_ref-44" class="reference"><a href="#cite_note-44"><span class="cite-bracket">[</span>44<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading4"><h4 id="Implications_for_Cocoa_development">Implications for Cocoa development</h4></div>
<style data-mw-deduplicate="TemplateStyles:r1251242444">
/* start https://en.wikipedia.org/ */


.mw-parser-output .ambox{border:1px solid #a2a9b1;border-left:10px solid #36c;background-color:#fbfbfb;box-sizing:border-box}.mw-parser-output .ambox+link+.ambox,.mw-parser-output .ambox+link+style+.ambox,.mw-parser-output .ambox+link+link+.ambox,.mw-parser-output .ambox+.mw-empty-elt+link+.ambox,.mw-parser-output .ambox+.mw-empty-elt+link+style+.ambox,.mw-parser-output .ambox+.mw-empty-elt+link+link+.ambox{margin-top:-1px}html body.mediawiki .mw-parser-output .ambox.mbox-small-left{margin:4px 1em 4px 0;overflow:hidden;width:238px;border-collapse:collapse;font-size:88%;line-height:1.25em}.mw-parser-output .ambox-speedy{border-left:10px solid #b32424;background-color:#fee7e6}.mw-parser-output .ambox-delete{border-left:10px solid #b32424}.mw-parser-output .ambox-content{border-left:10px solid #f28500}.mw-parser-output .ambox-style{border-left:10px solid #fc3}.mw-parser-output .ambox-move{border-left:10px solid #9932cc}.mw-parser-output .ambox-protection{border-left:10px solid #a2a9b1}.mw-parser-output .ambox .mbox-text{border:none;padding:0.25em 0.5em;width:100%}.mw-parser-output .ambox .mbox-image{border:none;padding:2px 0 2px 0.5em;text-align:center}.mw-parser-output .ambox .mbox-imageright{border:none;padding:2px 0.5em 2px 0;text-align:center}.mw-parser-output .ambox .mbox-empty-cell{border:none;padding:0;width:1px}.mw-parser-output .ambox .mbox-image-div{width:52px}@media(min-width:720px){.mw-parser-output .ambox{margin:0 10%}}@media print{body.ns-0 .mw-parser-output .ambox{display:none!important}}


/* end https://en.wikipedia.org/ */
</style>
<p>All Objective-C applications developed for macOS that make use of the above improvements for Objective-C 2.0 are incompatible with all operating systems prior to 10.5 (Leopard). Since fast enumeration does not generate exactly the same binaries as standard enumeration, its use will cause an application to crash on Mac OS X version 10.4 or earlier.
</p>
<div class="mw-heading mw-heading3"><h3 id="Blocks">Blocks</h3></div>
<style data-mw-deduplicate="TemplateStyles:r1236090951">
/* start https://en.wikipedia.org/ */


.mw-parser-output .hatnote{font-style:italic}.mw-parser-output div.hatnote{padding-left:1.6em;margin-bottom:0.5em}.mw-parser-output .hatnote i{font-style:normal}.mw-parser-output .hatnote+link+.hatnote{margin-top:-0.5em}@media print{body.ns-0 .mw-parser-output .hatnote{display:none!important}}


/* end https://en.wikipedia.org/ */
</style><div role="note" class="hatnote navigation-not-searchable">Main article: <a href="Blocks_(C_language_extension)" title="Blocks (C language extension)">Blocks (C language extension)</a></div>
<p>Blocks is a nonstandard extension for Objective-C (and <a href="C_(programming_language)" title="C (programming language)">C</a> and <a href="C%2B%2B" title="C++">C++</a>) that uses special syntax to create <a href="Closure_(programming)" class="mw-redirect" title="Closure (programming)">closures</a>. Blocks are only supported in <a href="Mac_OS_X_Snow_Leopard" title="Mac OS X Snow Leopard">Mac OS X 10.6 "Snow Leopard"</a> or later, <a href="IOS_4" title="IOS 4">iOS 4</a> or later, and GNUstep with libobjc2 1.7 and compiling with <a href="Clang" title="Clang">clang</a> 3.1 or later.<sup id="cite_ref-Blocks_requirements_45-0" class="reference"><a href="#cite_note-Blocks_requirements-45"><span class="cite-bracket">[</span>45<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-highlight mw-highlight-lang-objc mw-content-ltr" dir="ltr"><pre><span class="cp">#include</span><span class="w"> </span><span class="cpf">&lt;stdio.h&gt;</span>
<span class="cp">#include</span><span class="w"> </span><span class="cpf">&lt;Block.h&gt;</span>
<span class="k">typedef</span><span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="p">(</span><span class="o">^</span><span class="n">IntBlock</span><span class="p">)();</span>

<span class="n">IntBlock</span><span class="w"> </span><span class="nf">MakeCounter</span><span class="p">(</span><span class="kt">int</span><span class="w"> </span><span class="n">start</span><span class="p">,</span><span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">increment</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="k">__block</span><span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">start</span><span class="p">;</span>

<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="n">Block_copy</span><span class="p">(</span><span class="w"> </span><span class="o">^</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">ret</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">i</span><span class="p">;</span>
<span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">+=</span><span class="w"> </span><span class="n">increment</span><span class="p">;</span>
<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="n">ret</span><span class="p">;</span>
<span class="w"> </span><span class="p">});</span>

<span class="p">}</span>

<span class="kt">int</span><span class="w"> </span><span class="nf">main</span><span class="p">(</span><span class="kt">void</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="n">IntBlock</span><span class="w"> </span><span class="n">mycounter</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">MakeCounter</span><span class="p">(</span><span class="mi">5</span><span class="p">,</span><span class="w"> </span><span class="mi">2</span><span class="p">);</span>
<span class="w"> </span><span class="n">printf</span><span class="p">(</span><span class="s">"First call: %d</span><span class="se">\n</span><span class="s">"</span><span class="p">,</span><span class="w"> </span><span class="n">mycounter</span><span class="p">());</span>
<span class="w"> </span><span class="n">printf</span><span class="p">(</span><span class="s">"Second call: %d</span><span class="se">\n</span><span class="s">"</span><span class="p">,</span><span class="w"> </span><span class="n">mycounter</span><span class="p">());</span>
<span class="w"> </span><span class="n">printf</span><span class="p">(</span><span class="s">"Third call: %d</span><span class="se">\n</span><span class="s">"</span><span class="p">,</span><span class="w"> </span><span class="n">mycounter</span><span class="p">());</span>

<span class="w"> </span><span class="cm">/* because it was copied, it must also be released */</span>
<span class="w"> </span><span class="n">Block_release</span><span class="p">(</span><span class="n">mycounter</span><span class="p">);</span>

<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="mi">0</span><span class="p">;</span>
<span class="p">}</span>
<span class="cm">/* Output:</span>
<span class="cm"> First call: 5</span>
<span class="cm"> Second call: 7</span>
<span class="cm"> Third call: 9</span>
<span class="cm">*/</span>
</pre></div>
<div class="mw-heading mw-heading3"><h3 id="Modern_Objective-C">Modern Objective-C</h3></div>
<p>Apple has added some additional features to Objective 2.0 over time. The additions only apply to the "Apple <a href="LLVM" title="LLVM">LLVM</a> compiler", i.e. clang frontend of the language. Confusingly, the versioning used by Apple differs from that of the LLVM upstream; refer to <a href="Xcode#Toolchain_versions" title="Xcode">Xcode §&nbsp;Toolchain versions</a> for a translation to open-source LLVM version numbers.<sup id="cite_ref-llvm-ver_46-0" class="reference"><a href="#cite_note-llvm-ver-46"><span class="cite-bracket">[</span>46<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading4"><h4 id="Automatic_Reference_Counting">Automatic Reference Counting</h4></div>
<div role="note" class="hatnote navigation-not-searchable">Main article: <a href="Automatic_Reference_Counting" title="Automatic Reference Counting">Automatic Reference Counting</a></div>
<p>Automatic Reference Counting (ARC) is a compile-time feature that eliminates the need for programmers to manually manage retain counts using <code>retain</code> and <code>release</code>.<sup id="cite_ref-Transitioning_to_ARC_47-0" class="reference"><a href="#cite_note-Transitioning_to_ARC-47"><span class="cite-bracket">[</span>47<span class="cite-bracket">]</span></a></sup> Unlike <a href="Garbage_collection_(computer_science)" title="Garbage collection (computer science)">garbage collection</a>, which occurs at run time, ARC eliminates the overhead of a separate process managing retain counts. ARC and manual memory management are not mutually exclusive; programmers can continue to use non-ARC code in ARC-enabled projects by disabling ARC for individual code files. Xcode can also attempt to automatically upgrade a project to ARC.
</p><p>ARC was introduced in LLVM 3.0. This translates to Xcode 4.2 (2011), or Apple LLVM compiler 3.0.<sup id="cite_ref-48" class="reference"><a href="#cite_note-48"><span class="cite-bracket">[</span>48<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading4"><h4 id="Literals">Literals</h4></div>
<p>NeXT and Apple Obj-C runtimes have long included a short-form way to create new strings, using the literal syntax <code>@"a new string"</code>, or drop to CoreFoundation constants <code>kCFBooleanTrue</code> and <code>kCFBooleanFalse</code> for <code>NSNumber</code> with Boolean values. Using this format saves the programmer from having to use the longer <code>initWithString:</code> or similar methods when doing certain operations.
</p><p>When using Apple <a href="LLVM" title="LLVM">LLVM</a> compiler 4.0 (Xcode 4.4) or later, arrays, dictionaries, and numbers (<code>NSArray</code>, <code>NSDictionary</code>, <code>NSNumber</code> classes) can also be created using literal syntax instead of methods.<sup id="cite_ref-Programming_with_Obj-C_–_Values_and_Collections_49-0" class="reference"><a href="#cite_note-Programming_with_Obj-C_–_Values_and_Collections-49"><span class="cite-bracket">[</span>49<span class="cite-bracket">]</span></a></sup> (Apple LLVM compiler 4.0 translates to open source LLVM and Clang 3.1.)<sup id="cite_ref-llvm31_50-0" class="reference"><a href="#cite_note-llvm31-50"><span class="cite-bracket">[</span>50<span class="cite-bracket">]</span></a></sup>
</p><p>Example without literals:
</p>
<div class="mw-highlight mw-highlight-lang-objc mw-content-ltr" dir="ltr"><pre><span class="bp">NSArray</span><span class="w"> </span><span class="o">*</span><span class="n">myArray</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="bp">NSArray</span><span class="w"> </span><span class="n">arrayWithObjects</span><span class="o">:</span><span class="n">object1</span><span class="p">,</span><span class="n">object2</span><span class="p">,</span><span class="n">object3</span><span class="p">,</span><span class="nb">nil</span><span class="p">];</span>
<span class="bp">NSDictionary</span><span class="w"> </span><span class="o">*</span><span class="n">myDictionary1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="bp">NSDictionary</span><span class="w"> </span><span class="n">dictionaryWithObject</span><span class="o">:</span><span class="n">someObject</span><span class="w"> </span><span class="n">forKey</span><span class="o">:</span><span class="s">@"key"</span><span class="p">];</span>
<span class="bp">NSDictionary</span><span class="w"> </span><span class="o">*</span><span class="n">myDictionary2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="bp">NSDictionary</span><span class="w"> </span><span class="n">dictionaryWithObjectsAndKeys</span><span class="o">:</span><span class="n">object1</span><span class="p">,</span><span class="w"> </span><span class="n">key1</span><span class="p">,</span><span class="w"> </span><span class="n">object2</span><span class="p">,</span><span class="w"> </span><span class="n">key2</span><span class="p">,</span><span class="w"> </span><span class="nb">nil</span><span class="p">];</span>
<span class="bp">NSNumber</span><span class="w"> </span><span class="o">*</span><span class="n">myNumber</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="bp">NSNumber</span><span class="w"> </span><span class="n">numberWithInt</span><span class="o">:</span><span class="n">myInt</span><span class="p">];</span>
<span class="bp">NSNumber</span><span class="w"> </span><span class="o">*</span><span class="n">mySumNumber</span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="bp">NSNumber</span><span class="w"> </span><span class="n">numberWithInt</span><span class="o">:</span><span class="p">(</span><span class="mi">2</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">3</span><span class="p">)];</span>
<span class="bp">NSNumber</span><span class="w"> </span><span class="o">*</span><span class="n">myBoolNumber</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="bp">NSNumber</span><span class="w"> </span><span class="n">numberWithBool</span><span class="o">:</span><span class="nb">YES</span><span class="p">];</span>
</pre></div>
<p>Example with literals:
</p>
<div class="mw-highlight mw-highlight-lang-objc mw-content-ltr" dir="ltr"><pre><span class="bp">NSArray</span><span class="w"> </span><span class="o">*</span><span class="n">myArray</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="l">@[</span><span class="w"> </span><span class="n">object1</span><span class="p">,</span><span class="w"> </span><span class="n">object2</span><span class="p">,</span><span class="w"> </span><span class="n">object3</span><span class="w"> </span><span class="l">]</span><span class="p">;</span>
<span class="bp">NSDictionary</span><span class="w"> </span><span class="o">*</span><span class="n">myDictionary1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="l">@{</span><span class="w"> </span><span class="s">@"key"</span><span class="w"> </span><span class="o">:</span><span class="w"> </span><span class="n">someObject</span><span class="w"> </span><span class="l">}</span><span class="p">;</span>
<span class="bp">NSDictionary</span><span class="w"> </span><span class="o">*</span><span class="n">myDictionary2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="l">@{</span><span class="w"> </span><span class="n">key1</span><span class="o">:</span><span class="w"> </span><span class="n">object1</span><span class="p">,</span><span class="w"> </span><span class="n">key2</span><span class="o">:</span><span class="w"> </span><span class="n">object2</span><span class="w"> </span><span class="l">}</span><span class="p">;</span>
<span class="bp">NSNumber</span><span class="w"> </span><span class="o">*</span><span class="n">myNumber</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="l">@(</span><span class="n">myInt</span><span class="l">)</span><span class="p">;</span>
<span class="bp">NSNumber</span><span class="w"> </span><span class="o">*</span><span class="n">mySumNumber</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="l">@(</span><span class="mi">2</span><span class="o">+</span><span class="mi">3</span><span class="l">)</span><span class="p">;</span>
<span class="bp">NSNumber</span><span class="w"> </span><span class="o">*</span><span class="n">myBoolNumber</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="m">@YES</span><span class="p">;</span>
<span class="bp">NSNumber</span><span class="w"> </span><span class="o">*</span><span class="n">myIntegerNumber</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">@8</span><span class="p">;</span>
</pre></div>
<p>In Xcode versions before 13, unlike string literals, array, dictionary, and number literals were compiled into code equivalent to the above method calls. In particular, under manually reference-counted memory management, these objects were autoreleased, which required added care when, for example, used with function-static variables or other kinds of globals.
</p><p>In Xcode 13 (clang version 13.0.0 <sup id="cite_ref-51" class="reference"><a href="#cite_note-51"><span class="cite-bracket">[</span>51<span class="cite-bracket">]</span></a></sup>) and later, array, dictionary, and number literals can also be embedded into the binary at compile time, just like string literals. This feature is enabled by default on Apple platforms and can be controlled with the <code>-fno-objc-constant-literals</code> and related compiler flags. <sup id="cite_ref-52" class="reference"><a href="#cite_note-52"><span class="cite-bracket">[</span>52<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading4"><h4 id="Subscripting">Subscripting</h4></div>
<p>When using Apple <a href="LLVM" title="LLVM">LLVM</a> compiler 4.0 or later, arrays and dictionaries (<code>NSArray</code> and <code>NSDictionary</code> classes) can be manipulated using subscripting.<sup id="cite_ref-Programming_with_Obj-C_–_Values_and_Collections_49-1" class="reference"><a href="#cite_note-Programming_with_Obj-C_–_Values_and_Collections-49"><span class="cite-bracket">[</span>49<span class="cite-bracket">]</span></a></sup> Subscripting can be used to retrieve values from indexes (array) or keys (dictionary), and with mutable objects, can also be used to set objects to indexes or keys. In code, subscripting is represented using brackets <code>[ ]</code>.<sup id="cite_ref-ObjCLiterals_53-0" class="reference"><a href="#cite_note-ObjCLiterals-53"><span class="cite-bracket">[</span>53<span class="cite-bracket">]</span></a></sup>
</p><p>Example without subscripting:
</p>
<div class="mw-highlight mw-highlight-lang-objc mw-content-ltr" dir="ltr"><pre><span class="kt">id</span><span class="w"> </span><span class="n">object1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="n">someArray</span><span class="w"> </span><span class="n">objectAtIndex</span><span class="o">:</span><span class="mi">0</span><span class="p">];</span>
<span class="kt">id</span><span class="w"> </span><span class="n">object2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="n">someDictionary</span><span class="w"> </span><span class="n">objectForKey</span><span class="o">:</span><span class="s">@"key"</span><span class="p">];</span>
<span class="p">[</span><span class="n">someMutableArray</span><span class="w"> </span><span class="n">replaceObjectAtIndex</span><span class="o">:</span><span class="mi">0</span><span class="w"> </span><span class="n">withObject</span><span class="o">:</span><span class="n">object3</span><span class="p">];</span>
<span class="p">[</span><span class="n">someMutableDictionary</span><span class="w"> </span><span class="n">setObject</span><span class="o">:</span><span class="n">object4</span><span class="w"> </span><span class="n">forKey</span><span class="o">:</span><span class="s">@"key"</span><span class="p">];</span>
</pre></div>
<p>Example with subscripting:
</p>
<div class="mw-highlight mw-highlight-lang-objc mw-content-ltr" dir="ltr"><pre><span class="kt">id</span><span class="w"> </span><span class="n">object1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">someArray</span><span class="p">[</span><span class="mi">0</span><span class="p">];</span>
<span class="kt">id</span><span class="w"> </span><span class="n">object2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">someDictionary</span><span class="p">[</span><span class="s">@"key"</span><span class="p">];</span>
<span class="n">someMutableArray</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">object3</span><span class="p">;</span>
<span class="n">someMutableDictionary</span><span class="p">[</span><span class="s">@"key"</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">object4</span><span class="p">;</span>
</pre></div>
<div class="mw-heading mw-heading3"><h3 id="&quot;Modern&quot;_Objective-C_syntax_(1997)">"Modern" Objective-C syntax (1997)</h3></div>
<p>After the purchase of NeXT by Apple, attempts were made to make the language more acceptable to programmers more familiar with <a href="Java_(programming_language)" title="Java (programming language)">Java</a> than Smalltalk. One of these attempts was introducing what was termed "Modern Syntax" for Objective-C at the time<sup id="cite_ref-54" class="reference"><a href="#cite_note-54"><span class="cite-bracket">[</span>54<span class="cite-bracket">]</span></a></sup> (in contrast to the current, "classic" syntax). There was no change in behaviour, this was merely an alternative syntax. Instead of writing a method invocation like:
</p>
<div class="mw-highlight mw-highlight-lang-objc mw-content-ltr" dir="ltr"><pre><span class="w"> </span><span class="n">object</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[[</span><span class="bp">MyClass</span><span class="w"> </span><span class="n">alloc</span><span class="p">]</span><span class="w"> </span><span class="n">init</span><span class="p">];</span>
<span class="w"> </span><span class="p">[</span><span class="n">object</span><span class="w"> </span><span class="n">firstLabel</span><span class="o">:</span><span class="w"> </span><span class="n">param1</span><span class="w"> </span><span class="n">secondLabel</span><span class="o">:</span><span class="w"> </span><span class="n">param2</span><span class="p">];</span>
</pre></div>
<p>It was instead written as
</p>
<div class="mw-highlight mw-highlight-lang-objc mw-content-ltr" dir="ltr"><pre><span class="w"> </span><span class="n">object</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="bp">MyClass</span><span class="p">.</span><span class="n">alloc</span><span class="p">).</span><span class="n">init</span><span class="p">;</span>
<span class="w"> </span><span class="n">object</span><span class="p">.</span><span class="n">labels</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="n">param1</span><span class="p">,</span><span class="w"> </span><span class="n">param2</span><span class="w"> </span><span class="p">);</span>
</pre></div>
<p>Similarly, declarations went from the form
</p>
<div class="mw-highlight mw-highlight-lang-objc mw-content-ltr" dir="ltr"><pre><span class="w"> </span><span class="o">-</span><span class="p">(</span><span class="kt">void</span><span class="p">)</span><span class="w"> </span><span class="n">firstLabel</span><span class="o">:</span><span class="w"> </span><span class="p">(</span><span class="kt">int</span><span class="p">)</span><span class="n">param1</span><span class="w"> </span><span class="n">secondLabel</span><span class="o">:</span><span class="w"> </span><span class="p">(</span><span class="kt">int</span><span class="p">)</span><span class="n">param2</span><span class="p">;</span>
</pre></div>
<p>to
</p>
<div class="mw-highlight mw-highlight-lang-objc mw-content-ltr" dir="ltr"><pre><span class="w"> </span><span class="o">-</span><span class="p">(</span><span class="kt">void</span><span class="p">)</span><span class="w"> </span><span class="n">labels</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">param1</span><span class="p">,</span><span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">param2</span><span class="w"> </span><span class="p">);</span>
</pre></div>
<p>This "modern" syntax is no longer supported in current dialects of the Objective-C language.
</p>
<div class="mw-heading mw-heading3"><h3 id="mulle-objc">mulle-objc</h3></div>
<p>The <a rel="nofollow" class="external text" href="https://mulle-objc.github.io/">mulle-objc</a> project is another re-implementation of Objective-C. It supports <a href="GNU_Compiler_Collection" title="GNU Compiler Collection">GCC</a> or <a href="Clang" title="Clang">Clang</a>/<a href="LLVM" title="LLVM">LLVM</a> compilers as backends. It diverges from other runtimes in terms of syntax, semantics and ABI compatibility. It supports Linux, FreeBSD, and Windows.
</p>
<div class="mw-heading mw-heading3"><h3 id="Portable_Object_Compiler">Portable Object Compiler</h3></div>
<p>Besides the <a href="GNU_Compiler_Collection" title="GNU Compiler Collection">GCC</a>/<a href="NeXT" title="NeXT">NeXT</a>/<a href="Apple_Inc." title="Apple Inc.">Apple</a> implementation, which added several extensions to the original <a href="Stepstone" class="mw-redirect" title="Stepstone">Stepstone</a> implementation, another <a href="Free_and_open_source_software" class="mw-redirect" title="Free and open source software">free, open-source</a> Objective-C implementation called the Portable Object Compiler also exists.<sup id="cite_ref-55" class="reference"><a href="#cite_note-55"><span class="cite-bracket">[</span>55<span class="cite-bracket">]</span></a></sup> The set of extensions implemented by the Portable Object Compiler differs from the GCC/NeXT/Apple implementation; in particular, it includes <a href="Smalltalk" title="Smalltalk">Smalltalk</a>-like blocks for Objective-C, while it lacks protocols and categories, two features used extensively in OpenStep and its derivatives and relatives. Overall, POC represents an older, pre-NeXT stage in the language's evolution, roughly conformant to Brad Cox's 1991 book.
</p><p>It also includes a runtime library called ObjectPak, which is based on Cox's original ICPak101 library (which in turn derives from the Smalltalk-80 class library), and is quite radically different from the OpenStep FoundationKit.
</p>
<div class="mw-heading mw-heading3"><h3 id="GEOS_Objective-C">GEOS Objective-C</h3></div>
<p>The <a href="GEOS_(16-bit_operating_system)" title="GEOS (16-bit operating system)">PC GEOS</a> system used a programming language known as <b>GEOS Objective-C</b> or <b>goc</b>;<sup id="cite_ref-56" class="reference"><a href="#cite_note-56"><span class="cite-bracket">[</span>56<span class="cite-bracket">]</span></a></sup> despite the name similarity, the two languages are similar only in overall concept and the use of keywords prefixed with an @ sign.
</p>
<div class="mw-heading mw-heading3"><h3 id="Clang">Clang</h3></div>
<p>The <a href="Clang" title="Clang">Clang</a> compiler suite, part of the <a href="LLVM" title="LLVM">LLVM</a> project, implements Objective-C and other languages. After GCC 4.3 (2008) switched to GPLv3, Apple abandoned it in favor of clang, a compiler it has more legal power to modify. As a result, many of the modern Objective-C language features are supported only by Clang.
</p><p>Apple's versioning scheme for its clang-based "LLVM compiler" differs from the LLVM's open-source versioning. See <a href="Xcode#Toolchain_versions" title="Xcode">Xcode §&nbsp;Toolchain versions</a> for a translation<sup id="cite_ref-llvm-ver_46-1" class="reference"><a href="#cite_note-llvm-ver-46"><span class="cite-bracket">[</span>46<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading3"><h3 id="GNU,_GNUstep,_and_WinObjC">GNU, GNUstep, and WinObjC</h3></div>
<p>The GNU project has, for a long time, been interested in a platform to port NeXT and Obj-C programs to. The ChangeLog for the <span class="monospaced">libobjc</span> directory in GCC suggests that it existed before 1998 (GCC 2.95), and its README further points at a rewrite in 1993 (GCC 2.4).<sup id="cite_ref-57" class="reference"><a href="#cite_note-57"><span class="cite-bracket">[</span>57<span class="cite-bracket">]</span></a></sup>
</p><p>The NeXT frontend source code was released since it was made as part of GCC, released <a href="GNU_General_Public_License" title="GNU General Public License">GNU General Public License</a> which forces ones making derivative works to do so. Apple continued this tradition in releasing its fork of GCC up to 4.2.1, after which they abandoned the compiler. GCC maintainers took in the changes, but did not invest much in supporting newer features such as the Objective-C 2.0 language.<sup id="cite_ref-objc2-faq_35-1" class="reference"><a href="#cite_note-objc2-faq-35"><span class="cite-bracket">[</span>35<span class="cite-bracket">]</span></a></sup><sup class="reference nowrap"><span title="Location: Which compiler">: Which compiler </span></sup>
</p><p>The GNUstep developers, interested in the new language, forked the GCC <span class="monospaced">libobjc</span> to a project independent of GCC called <span class="monospaced">libobjc2</span> in 2009. They also arranged for the runtime to be used with Clang to take advantage of the new language syntax.<sup id="cite_ref-objc2-faq_35-2" class="reference"><a href="#cite_note-objc2-faq-35"><span class="cite-bracket">[</span>35<span class="cite-bracket">]</span></a></sup><sup class="reference nowrap"><span title="Location: Which compiler">: Which compiler </span></sup> GCC moved slowly at the same time, but at GCC 4.6.0 (2011) they have moved on to Objective-C 2.0 in their libobjc as well.<sup id="cite_ref-gcc46_34-1" class="reference"><a href="#cite_note-gcc46-34"><span class="cite-bracket">[</span>34<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-58" class="reference"><a href="#cite_note-58"><span class="cite-bracket">[</span>58<span class="cite-bracket">]</span></a></sup> GNUstep documentation suggest that the GCC implementation still lacks support for blocks, non-fragile variables, and the newer ARC.<sup id="cite_ref-objc2-faq_35-3" class="reference"><a href="#cite_note-objc2-faq-35"><span class="cite-bracket">[</span>35<span class="cite-bracket">]</span></a></sup><sup class="reference nowrap"><span title="Location: Which runtime">: Which runtime </span></sup>
</p><p><a href="Microsoft" title="Microsoft">Microsoft</a> forked ObjFW's runtime into a part of <a href="WinObjC" class="mw-redirect" title="WinObjC">WinObjC</a>, the iOS bridge for <a href="Universal_Windows_Platform" title="Universal Windows Platform">Universal Windows Platform</a>, in 2015, though switched to a fork of <span class="monospaced">libobjc2</span> in 2016. Combined with its own implementation of <a href="Cocoa_Touch" class="mw-redirect" title="Cocoa Touch">Cocoa Touch</a> and underlying APIs, the project allows the reuse of iOS Application code inside of UWP apps.<sup id="cite_ref-59" class="reference"><a href="#cite_note-59"><span class="cite-bracket">[</span>59<span class="cite-bracket">]</span></a></sup>
</p><p>On Windows, Objective-C Development tools are provided for download on GNUStep's website. The GNUStep Development System consists of the following packages: GNUstep <a href="MinGW" title="MinGW">MSYS</a> System, GNUstep Core, GNUstep Devel, GNUstep Cairo, ProjectCenter IDE (Like Xcode, but not as complex), Gorm (Interface Builder Like Xcode NIB builder). These binary installers have not been updated since 2016,<sup id="cite_ref-60" class="reference"><a href="#cite_note-60"><span class="cite-bracket">[</span>60<span class="cite-bracket">]</span></a></sup> so it could be a better idea to just install by building under <a href="Cygwin" title="Cygwin">Cygwin</a> or <a href="MSYS2" class="mw-redirect" title="MSYS2">MSYS2</a> instead.
</p>
<div class="mw-heading mw-heading2"><h2 id="Library_use">Library use</h2></div>
<p>Objective-C today is often used in tandem with a fixed library of standard objects (often known as a "kit" or "framework"), such as <a href="Cocoa_(API)" title="Cocoa (API)">Cocoa</a>, <a href="GNUstep" title="GNUstep">GNUstep</a> or ObjFW. These libraries often come with the operating system: the GNUstep libraries often come with <a href="Linux" title="Linux">Linux</a>-based distributions and Cocoa comes with macOS. The programmer is not forced to inherit functions from the existing base class (NSObject – OFObject). Objective-C allows for the declaration of new root classes that do not inherit any existing function. Originally, Objective-C-based programming environments typically offered an Object class as the base class from which almost all other classes inherited. With the introduction of OpenStep, NeXT created a new base class named NSObject, which offered additional features over Object (an emphasis on using object references and reference counting instead of raw pointers, for example). Almost all classes in Cocoa inherit from NSObject.
</p><p>Not only did the renaming serve to differentiate the new default behavior of classes within the OpenStep API, but it allowed code that used Object—the original base class used on NeXTSTEP (and, more or less, other Objective-C class libraries)—to co-exist in the same runtime with code that used NSObject (with some limitations). The introduction of the two letter prefix also became a simplistic form of namespaces, which Objective-C lacks. Using a prefix to create an informal packaging identifier became an informal coding standard in the Objective-C community, and continues to this day.
</p><p>More recently, package managers have started appearing, such as <a href="CocoaPods" title="CocoaPods">CocoaPods</a>, which aims to be both a package manager and a repository of packages. A lot of open-source Objective-C code that was written in the last few years can now be installed using CocoaPods.
</p>
<div class="mw-heading mw-heading2"><h2 id="Analysis_of_the_language">Analysis of the language</h2></div>

<p>Objective-C implementations use a thin <a href="Run_time_system" class="mw-redirect" title="Run time system">runtime system</a> written in C, which adds little to the size of the application. In contrast, most object-oriented systems at the time that it was created used large <a href="Virtual_machine" title="Virtual machine">virtual machine</a> runtimes. Programs written in Objective-C tend to be not much larger than the size of their code and that of the libraries (which generally do not need to be included in the software distribution), in contrast to Smalltalk systems where a large amount of memory was used just to open a window. Objective-C applications tend to be larger than similar C or C++ applications because Objective-C dynamic typing does not allow methods to be stripped or inlined. Since the programmer has such freedom to delegate, forward calls, build selectors on the fly, and pass them to the runtime system, the Objective-C compiler cannot assume it is safe to remove unused methods or to inline calls.
</p><p>Likewise, the language can be implemented atop extant C compilers (in <a href="GNU_Compiler_Collection" title="GNU Compiler Collection">GCC</a>, first as a preprocessor, then as a module) rather than as a new compiler. This allows Objective-C to leverage the huge existing collection of C code, libraries, tools, etc. Existing C libraries can be wrapped in Objective-C <a href="Adapter_pattern" title="Adapter pattern">wrappers</a> to provide an OO-style interface. In this aspect, it is similar to <a href="GObject" title="GObject">GObject</a> library and <a href="Vala_(programming_language)" title="Vala (programming language)">Vala</a> language, which are widely used in development of <a href="GTK" title="GTK">GTK</a> applications.
</p><p>All of these practical changes lowered the <a href="Barriers_to_entry" title="Barriers to entry">barrier to entry</a>, likely the biggest problem for the widespread acceptance of Smalltalk in the 1980s.
</p><p>A common criticism is that Objective-C does not have language support for <a href="Namespaces" class="mw-redirect" title="Namespaces">namespaces</a>. Instead, programmers are forced to add prefixes to their class names, which are traditionally shorter than namespace names and thus more prone to collisions. As of 2007, all macOS classes and functions in the <a href="Cocoa_(software)" class="mw-redirect" title="Cocoa (software)">Cocoa</a> programming environment are prefixed with "NS" (e.g. NSObject, NSButton) to identify them as belonging to the macOS or iOS core; the "NS" derives from the names of the classes as defined during the development of <a href="NeXTSTEP" title="NeXTSTEP">NeXTSTEP</a>.
</p><p>Since Objective-C is a strict superset of C, it does not treat C primitive types as <a href="First-class_object" class="mw-redirect" title="First-class object">first-class objects</a>.
</p><p>Unlike <a href="C%2B%2B" title="C++">C++</a>, Objective-C does not support <a href="Operator_overloading" title="Operator overloading">operator overloading</a>. Also unlike C++, Objective-C allows an object to directly inherit from only one class (forbidding <a href="Multiple_inheritance" title="Multiple inheritance">multiple inheritance</a>). However, in most cases, categories and protocols may be used as alternative ways to achieve the same results.
</p><p>Because Objective-C uses dynamic runtime typing and because all method calls are function calls (or, in some cases, syscalls), many common performance optimizations cannot be applied to Objective-C methods (for example: inlining, constant propagation, interprocedural optimizations, and scalar replacement of aggregates). This limits the performance of Objective-C abstractions relative to similar abstractions in languages such as C++ where such optimizations are possible.
</p>
<div class="mw-heading mw-heading3"><h3 id="Memory_management">Memory management</h3></div>
<p>The first versions of Objective-C did not support <a href="Garbage_collection_(computer_science)" title="Garbage collection (computer science)">garbage collection</a>. At the time this decision was a matter of some debate, and many people considered long "dead times" (when Smalltalk performed collection) to render the entire system unusable. Some 3rd party implementations have added this feature (most notably GNUstep using <a href="Boehm_garbage_collector" title="Boehm garbage collector">Boehm</a>), and Apple has implemented it as of <a href="Mac_OS_X_v10.5" class="mw-redirect" title="Mac OS X v10.5">Mac OS X v10.5</a>.<sup id="cite_ref-61" class="reference"><a href="#cite_note-61"><span class="cite-bracket">[</span>61<span class="cite-bracket">]</span></a></sup> However, in more recent versions of macOS and iOS, garbage collection has been deprecated in favor of <a href="Automatic_Reference_Counting" title="Automatic Reference Counting">Automatic Reference Counting</a> (ARC), introduced in 2011.
</p><p>With ARC, the compiler inserts retain and release calls automatically into Objective-C code based on <a href="Static_program_analysis" title="Static program analysis">static code analysis</a>. The automation relieves the programmer of having to write in memory management code. ARC also adds weak references to the Objective-C language.<sup id="cite_ref-62" class="reference"><a href="#cite_note-62"><span class="cite-bracket">[</span>62<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading3"><h3 id="Philosophical_differences_between_Objective-C_and_C++">Philosophical differences between Objective-C and C++</h3></div>
<p>The design and implementation of <a href="C%2B%2B" title="C++">C++</a> and Objective-C represent fundamentally different approaches to extending C.
</p><p>In addition to C's style of procedural programming, C++ directly supports certain forms of <a href="Object-oriented_programming" title="Object-oriented programming">object-oriented programming</a>, <a href="Generic_programming" title="Generic programming">generic programming</a>, and <a href="Metaprogramming" title="Metaprogramming">metaprogramming</a>. C++ also comes with <a href="C%2B%2B_Standard_Library" title="C++ Standard Library">a large standard library</a> that includes <a href="Sequence_container_(C%2B%2B)" title="Sequence container (C++)">several container classes</a>. Similarly, Objective-C adds <a href="Polymorphism_(computer_science)" title="Polymorphism (computer science)">object-oriented programming</a>, <a href="Dynamic_typing" class="mw-redirect" title="Dynamic typing">dynamic typing</a>, and <a href="Reflective_programming" title="Reflective programming">reflection</a> to C. Objective-C does not provide a standard library <i>per se</i>, but in most places where Objective-C is used, it is used with an <a href="OpenStep" title="OpenStep">OpenStep</a>-like library such as <a href="OPENSTEP" class="mw-redirect" title="OPENSTEP">OPENSTEP</a>, <a href="Cocoa_(API)" title="Cocoa (API)">Cocoa</a>, or <a href="GNUstep" title="GNUstep">GNUstep</a>, which provides functions similar to C++'s standard library.
</p><p>One notable difference is that Objective-C provides runtime support for <a href="Reflective_programming" title="Reflective programming">reflective programming</a> features, whereas C++ adds only a small amount of runtime support to C. In Objective-C, an object can be queried about its own properties, e.g., whether it will respond to a certain message. In C++, this is not possible without the use of external libraries.
</p><p>The use of reflection is part of the wider distinction between dynamic (run-time) features and static (compile-time) features of a language. Although Objective-C and C++ each employ a mix of both features, Objective-C favors run-time decisions while C++ favors compile-time decisions. The tension between dynamic and static programming involves many of the classic trade-offs in programming: dynamic features add flexibility, static features add speed and type checking.
</p><p><a href="Generic_programming" title="Generic programming">Generic programming</a> and metaprogramming can be implemented in both languages using runtime polymorphism (<a href="Dynamic_dispatch" title="Dynamic dispatch">dynamic dispatch</a>). In C++, this takes the form of <a href="Virtual_function" title="Virtual function">virtual functions</a> and <a href="Runtime_type_identification" class="mw-redirect" title="Runtime type identification">runtime type identification</a>, while Objective-C offers dynamic typing and reflection. Both Objective-C and C++ support compile-time polymorphism (<a href="Generic_function" title="Generic function">generic functions</a>), with Objective-C adding this feature in 2015.
</p>
<div class="mw-heading mw-heading2"><h2 id="See_also">See also</h2></div>
<ul><li><a href="C_(programming_language)" title="C (programming language)">C (programming language)</a></li>
<li><a href="C%2B%2B" title="C++">C++</a></li>
<li><a href="CocoaPods" title="CocoaPods">CocoaPods</a></li>
<li><a href="Comparison_of_programming_languages" title="Comparison of programming languages">Comparison of programming languages</a></li>
<li><a href="GNUStep" class="mw-redirect" title="GNUStep">GNUStep</a></li>
<li><a href="IBM_System_Object_Model#Comparison_of_Support_for_Compiled_Class_Libraries" title="IBM System Object Model">Comparison with COM, GObject, SOM, Windows Runtime, XPCOM</a></li>
<li><a href="Swift_(programming_language)" title="Swift (programming language)">Swift (programming language)</a></li>
<li><a href="Xcode" title="Xcode">Xcode</a></li>
<li><a href="WinObjC" class="mw-redirect" title="WinObjC">WinObjC</a> (aka: Windows Bridge for iOS)</li></ul>
<div class="mw-heading mw-heading2"><h2 id="References">References</h2></div>
<style data-mw-deduplicate="TemplateStyles:r1239543626">
/* start https://en.wikipedia.org/ */


.mw-parser-output .reflist{margin-bottom:0.5em;list-style-type:decimal}@media screen{.mw-parser-output .reflist{font-size:90%}}.mw-parser-output .reflist .references{font-size:100%;margin-bottom:0;list-style-type:inherit}.mw-parser-output .reflist-columns-2{column-width:30em}.mw-parser-output .reflist-columns-3{column-width:25em}.mw-parser-output .reflist-columns{margin-top:0.3em}.mw-parser-output .reflist-columns ol{margin-top:0}.mw-parser-output .reflist-columns li{page-break-inside:avoid;break-inside:avoid-column}.mw-parser-output .reflist-upper-alpha{list-style-type:upper-alpha}.mw-parser-output .reflist-upper-roman{list-style-type:upper-roman}.mw-parser-output .reflist-lower-alpha{list-style-type:lower-alpha}.mw-parser-output .reflist-lower-greek{list-style-type:lower-greek}.mw-parser-output .reflist-lower-roman{list-style-type:lower-roman}


/* end https://en.wikipedia.org/ */
</style><div class="reflist">
<div class="mw-references-wrap mw-references-columns"><ol class="references">
<li id="cite_note-1"><span class="mw-cite-backlink"><b><a href="#cite_ref-1">^</a></b></span> <span class="reference-text"><style data-mw-deduplicate="TemplateStyles:r1238218222">
/* start https://en.wikipedia.org/ */


.mw-parser-output cite.citation{font-style:inherit;word-wrap:break-word}.mw-parser-output .citation q{quotes:"\"""\"""'""'"}.mw-parser-output .citation:target{background-color:rgba(0,127,255,0.133)}.mw-parser-output .id-lock-free.id-lock-free a{background:url("./mw/Lock-green.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-limited.id-lock-limited a,.mw-parser-output .id-lock-registration.id-lock-registration a{background:url("./mw/Lock-gray-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-subscription.id-lock-subscription a{background:url("./mw/Lock-red-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .cs1-ws-icon a{background:url("./mw/Wikisource-logo.svg")right 0.1em center/12px no-repeat}body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-free a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-limited a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-registration a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-subscription a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .cs1-ws-icon a{background-size:contain;padding:0 1em 0 0}.mw-parser-output .cs1-code{color:inherit;background:inherit;border:none;padding:inherit}.mw-parser-output .cs1-hidden-error{display:none;color:var(--color-error,#d33)}.mw-parser-output .cs1-visible-error{color:var(--color-error,#d33)}.mw-parser-output .cs1-maint{display:none;color:#085;margin-left:0.3em}.mw-parser-output .cs1-kern-left{padding-left:0.2em}.mw-parser-output .cs1-kern-right{padding-right:0.2em}.mw-parser-output .citation .mw-selflink{font-weight:inherit}@media screen{.mw-parser-output .cs1-format{font-size:95%}html.skin-theme-clientpref-night .mw-parser-output .cs1-maint{color:#18911f}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .cs1-maint{color:#18911f}}


/* end https://en.wikipedia.org/ */
</style><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/ocrtVersionsPlatforms.html">"Runtime Versions and Platforms"</a>. <i>Developer.apple.com</i>. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20160720034718/https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/ocrtVersionsPlatforms.html">Archived</a> from the original on July 20, 2016<span class="reference-accessdate">. Retrieved <span class="nowrap">December 24,</span> 2017</span>.</cite></span>
</li>
<li id="cite_note-lattner2014-2"><span class="mw-cite-backlink"><b><a href="#cite_ref-lattner2014_2-0">^</a></b></span> <span class="reference-text"><cite id="CITEREFLattner2014" class="citation web cs1">Lattner, Chris (June 3, 2014). <a rel="nofollow" class="external text" href="http://nondot.org/sabre/">"Chris Lattner's Homepage"</a>. Chris Lattner. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20140604061001/http://nondot.org/sabre/">Archived</a> from the original on June 4, 2014<span class="reference-accessdate">. Retrieved <span class="nowrap">June 3,</span> 2014</span>. <q>The Swift language is the product of tireless effort from a team of language experts, documentation gurus, compiler optimization ninjas, and an incredibly important internal dogfooding group who provided feedback to help refine and battle-test ideas. Of course, it also greatly benefited from the experiences hard-won by many other languages in the field, drawing ideas from Objective-C, Rust, <a href="Haskell" title="Haskell">Haskell</a>, <a href="Ruby_(programming_language)" title="Ruby (programming language)">Ruby</a>, <a href="Python_(programming_language)" title="Python (programming language)">Python</a>, <a href="C_Sharp_(programming_language)" title="C Sharp (programming language)">C#</a>, CLU, and far too many others to list.</q></cite></span>
</li>
<li id="cite_note-3"><span class="mw-cite-backlink"><b><a href="#cite_ref-3">^</a></b></span> <span class="reference-text"><cite id="CITEREFApple_Developer2013" class="citation web cs1">Apple Developer (April 23, 2013). <a rel="nofollow" class="external text" href="https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ObjectiveC/Introduction/introObjectiveC.html">"The Objective-C Programming Language (Introduction)"</a>. <a href="Apple_Inc." title="Apple Inc.">Apple Inc.</a> <a rel="nofollow" class="external text" href="https://web.archive.org/web/20181026174828/https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ObjectiveC/Introduction/introObjectiveC.html">Archived</a> from the original on October 26, 2018<span class="reference-accessdate">. Retrieved <span class="nowrap">February 15,</span> 2025</span>.</cite></span>
</li>
<li id="cite_note-4"><span class="mw-cite-backlink"><b><a href="#cite_ref-4">^</a></b></span> <span class="reference-text"><cite id="CITEREFSingh2003" class="citation web cs1">Singh, Amit (December 2003). <a rel="nofollow" class="external text" href="http://osxbook.com/book/bonus/ancient/whatismacosx/history.html">"A Brief History of Mac OS X"</a>. Mac OS X Internals. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20120514135706/http://osxbook.com/book/bonus/ancient/whatismacosx/history.html">Archived</a> from the original on May 14, 2012<span class="reference-accessdate">. Retrieved <span class="nowrap">June 11,</span> 2012</span>.</cite></span>
</li>
<li id="cite_note-:0-5"><span class="mw-cite-backlink"><b><a href="#cite_ref-:0_5-0">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://developer.apple.com/documentation#app-frameworks">"App Frameworks"</a>. Apple. June 2014. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20190216075924/https://developer.apple.com/documentation/#app-frameworks">Archived</a> from the original on February 16, 2019<span class="reference-accessdate">. Retrieved <span class="nowrap">February 13,</span> 2019</span>.</cite></span>
</li>
<li id="cite_note-Wired1-6"><span class="mw-cite-backlink"><b><a href="#cite_ref-Wired1_6-0">^</a></b></span> <span class="reference-text"><cite id="CITEREFGarling" class="citation magazine cs1">Garling, Caleb. <a rel="nofollow" class="external text" href="https://www.wired.com/wiredenterprise/2012/07/apple-objective-c/">"iPhone Coding Language Now World's Third Most Popular"</a>. <i><a href="Wired_(magazine)" title="Wired (magazine)">Wired</a></i>. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20130909060247/http://www.wired.com/wiredenterprise/2012/07/apple-objective-c/">Archived</a> from the original on September 9, 2013<span class="reference-accessdate">. Retrieved <span class="nowrap">May 20,</span> 2013</span>.</cite></span>
</li>
<li id="cite_note-7"><span class="mw-cite-backlink"><b><a href="#cite_ref-7">^</a></b></span> <span class="reference-text"><cite id="CITEREFWentk2009" class="citation book cs1">Wentk, Richard (2009). <a rel="nofollow" class="external text" href="https://books.google.com/books?id=vBglDfsAjVQC&amp;pg=PT23"><i>Cocoa: Volume 5 of Developer Reference Apple Developer Series</i></a>. John Wiley and Sons. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>978-0-470-49589-6</bdi>. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20170216085437/https://books.google.com/books?id=vBglDfsAjVQC&amp;pg=PT23">Archived</a> from the original on February 16, 2017<span class="reference-accessdate">. Retrieved <span class="nowrap">July 22,</span> 2016</span>.</cite></span>
</li>
<li id="cite_note-love2009-8"><span class="mw-cite-backlink"><b><a href="#cite_ref-love2009_8-0">^</a></b></span> <span class="reference-text"><cite id="CITEREFBiancuzziWarden2009" class="citation book cs1">Biancuzzi, Federico; Warden, Shane (2009). <a rel="nofollow" class="external text" href="https://books.google.com/books?id=yB1WwURwBUQC&amp;pg=PA242"><i>Masterminds of Programming</i></a>. <a href="O'Reilly_Media%2C_Inc." class="mw-redirect" title="O'Reilly Media, Inc.">O'Reilly Media, Inc.</a> pp.&nbsp;<span class="nowrap">242–</span>246. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>978-0-596-51517-1</bdi>. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20170217023011/https://books.google.com/books?id=yB1WwURwBUQC&amp;pg=PA242">Archived</a> from the original on February 17, 2017<span class="reference-accessdate">. Retrieved <span class="nowrap">July 22,</span> 2016</span>.</cite></span>
</li>
<li id="cite_note-9"><span class="mw-cite-backlink"><b><a href="#cite_ref-9">^</a></b></span> <span class="reference-text"><cite id="CITEREFCox1983" class="citation journal cs1"><a href="Brad_Cox" title="Brad Cox">Cox, Brad</a> (1983). <span class="id-lock-subscription" title="Paid subscription required"><a rel="nofollow" class="external text" href="https://portal.acm.org/citation.cfm?id=948095">"The object oriented pre-compiler: programming Smalltalk-80 methods in C language"</a></span>. <i>ACM SIGPLAN Notices</i>. <b>18</b> (1). New York, NY: <a href="Association_for_Computing_Machinery" title="Association for Computing Machinery">ACM</a>. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1145%2F948093.948095">10.1145/948093.948095</a>. <a href="S2CID_(identifier)" class="mw-redirect" title="S2CID (identifier)">S2CID</a>&nbsp;<a rel="nofollow" class="external text" href="https://api.semanticscholar.org/CorpusID:6975032">6975032</a><span class="reference-accessdate">. Retrieved <span class="nowrap">February 17,</span> 2011</span>.</cite></span>
</li>
<li id="cite_note-10"><span class="mw-cite-backlink"><b><a href="#cite_ref-10">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://github.com/JoshCheek/clisp/blob/master/doc/Why-CLISP-is-under-GPL">"Common Lisp and Readline"</a>. <i><a href="GitHub" title="GitHub">GitHub</a></i>. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20140906185259/http://clisp.cvs.sourceforge.net/viewvc/clisp/clisp/doc/Why-CLISP-is-under-GPL">Archived</a> from the original on September 6, 2014<span class="reference-accessdate">. Retrieved <span class="nowrap">September 15,</span> 2014</span>. <q>The issue first arose when NeXT proposed to distribute a modified GCC in two parts and let the user link them. Jobs asked me whether this was lawful. It seemed to me at the time that it was, following reasoning like what you are using; but since the result was very undesirable for free software, I said I would have to ask the lawyer. What the lawyer said surprised me; he said that judges would consider such schemes to be "subterfuges" and would be very harsh toward them. He said a judge would ask whether it is "really" one program, rather than how it is labeled. So I went back to Jobs and said we believed his plan was not allowed by the GPL. The direct result of this is that we now have an Objective-C front end. They had wanted to distribute the Objective C parser as a separate proprietary package to link with the GCC back end, but since I didn't agree this was allowed, they made it free.</q></cite></span>
</li>
<li id="cite_note-GNUstep_site-11"><span class="mw-cite-backlink"><b><a href="#cite_ref-GNUstep_site_11-0">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://www.gnustep.org/information/aboutGNUstep.html">"GNUstep: Introduction"</a>. GNUstep developers/GNU Project. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20120806172414/http://www.gnustep.org/information/aboutGNUstep.html">Archived</a> from the original on August 6, 2012<span class="reference-accessdate">. Retrieved <span class="nowrap">July 29,</span> 2012</span>.</cite></span>
</li>
<li id="cite_note-12"><span class="mw-cite-backlink"><b><a href="#cite_ref-12">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://www.linkedin.com/in/krestenkrabthorup">"Kresten Krab Thorup | LinkedIn"</a>. <i>www.linkedin.com</i>. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20140715173258/http://www.linkedin.com/in/krestenkrabthorup">Archived</a> from the original on July 15, 2014<span class="reference-accessdate">. Retrieved <span class="nowrap">June 23,</span> 2016</span>.</cite></span>
</li>
<li id="cite_note-13"><span class="mw-cite-backlink"><b><a href="#cite_ref-13">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://developer.apple.com/library/mac/referencelibrary/GettingStarted/RoadMapOSX/books/WriteObjective-CCode/WriteObjective-CCode/WriteObjective-CCode.html">"Write Objective-C Code"</a>. apple.com. April 23, 2013. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20131224083823/https://developer.apple.com/library/mac/referencelibrary/GettingStarted/RoadMapOSX/books/WriteObjective-CCode/WriteObjective-CCode/WriteObjective-CCode.html">Archived</a> from the original on December 24, 2013<span class="reference-accessdate">. Retrieved <span class="nowrap">December 22,</span> 2013</span>.</cite></span>
</li>
<li id="cite_note-14"><span class="mw-cite-backlink"><b><a href="#cite_ref-14">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://www.informit.com/articles/article.aspx?p=1765122">"Objective-C Boot Camp"</a>. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20180211131704/https://www.informit.com/articles/article.aspx?p=1765122">Archived</a> from the original on February 11, 2018<span class="reference-accessdate">. Retrieved <span class="nowrap">February 11,</span> 2018</span>. <q>Objective-C is a strict superset of ANSI C</q></cite></span>
</li>
<li id="cite_note-15"><span class="mw-cite-backlink"><b><a href="#cite_ref-15">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://www.drdobbs.com/examining-objective-c/184402055">"Examining Objective-C"</a>. <i>Dr. Dobb's</i>. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20140904203055/http://www.drdobbs.com/examining-objective-c/184402055">Archived</a> from the original on September 4, 2014<span class="reference-accessdate">. Retrieved <span class="nowrap">September 4,</span> 2014</span>. <q>Objective-C is an object-oriented strict superset of C</q></cite></span>
</li>
<li id="cite_note-16"><span class="mw-cite-backlink"><b><a href="#cite_ref-16">^</a></b></span> <span class="reference-text"><cite id="CITEREFLee2013" class="citation book cs1">Lee, Keith (September 3, 2013). <a rel="nofollow" class="external text" href="https://books.google.com/books?id=ec6zAAAAQBAJ&amp;pg=PA381"><i>Pro Objective-C</i></a>. Apress. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>9781430250500</bdi>. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20180514192627/https://books.google.com/books?id=ec6zAAAAQBAJ&amp;lpg=PA381&amp;ots=NoFaE3OEX0&amp;pg=PA381">Archived</a> from the original on May 14, 2018<span class="reference-accessdate">. Retrieved <span class="nowrap">December 24,</span> 2017</span> – via Google Books.</cite></span>
</li>
<li id="cite_note-17"><span class="mw-cite-backlink"><b><a href="#cite_ref-17">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://web.mit.edu/darwin/src/modules/headerdoc/Documentation/ObjCTags.html">"Tags for Objective-C Headers"</a>. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20170401034714/http://web.mit.edu/darwin/src/modules/headerdoc/Documentation/ObjCTags.html">Archived</a> from the original on April 1, 2017<span class="reference-accessdate">. Retrieved <span class="nowrap">February 11,</span> 2018</span>. <q>Objective-C is a superset of C</q></cite></span>
</li>
<li id="cite_note-18"><span class="mw-cite-backlink"><b><a href="#cite_ref-18">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://www-01.ibm.com/support/docview.wss?uid=swg24034606">"AppScan Source 8.7 now available"</a>. July 11, 2014. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20170203131125/http://www-01.ibm.com/support/docview.wss?uid=swg24034606">Archived</a> from the original on February 3, 2017<span class="reference-accessdate">. Retrieved <span class="nowrap">February 11,</span> 2018</span>. <q>The Objective-C programming language is a superset of the C programming language</q></cite></span>
</li>
<li id="cite_note-19"><span class="mw-cite-backlink"><b><a href="#cite_ref-19">^</a></b></span> <span class="reference-text"><cite id="CITEREFApple,_Inc.2009" class="citation web cs1"><a href="Apple%2C_Inc." class="mw-redirect" title="Apple, Inc.">Apple, Inc.</a> (October 19, 2009). <a rel="nofollow" class="external text" href="https://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/ocrtDynamicResolution.html">"Dynamic Method Resolution"</a>. <i>Objective-C Runtime Programming Guide</i>. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20100907080424/http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/ocrtDynamicResolution.html">Archived</a> from the original on September 7, 2010<span class="reference-accessdate">. Retrieved <span class="nowrap">November 25,</span> 2014</span>.</cite></span>
</li>
<li id="cite_note-20"><span class="mw-cite-backlink"><b><a href="#cite_ref-20">^</a></b></span> <span class="reference-text"><cite id="CITEREFApple,_Inc.2009" class="citation web cs1"><a href="Apple%2C_Inc." class="mw-redirect" title="Apple, Inc.">Apple, Inc.</a> (October 19, 2009). <a rel="nofollow" class="external text" href="https://web.archive.org/web/20100908132046/http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/ObjectiveC/Articles/ocSelectors.html">"Avoiding Messaging Errors"</a>. <i>The Objective-C Programming Language</i>. Archived from <a rel="nofollow" class="external text" href="https://developer.apple.com/mac/library/documentation/cocoa/conceptual/ObjectiveC/Articles/ocSelectors.html#//apple_ref/doc/uid/TP30001163-CH23-89447">the original</a> on September 8, 2010.</cite></span>
</li>
<li id="cite_note-21"><span class="mw-cite-backlink"><b><a href="#cite_ref-21">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://developer.apple.com/documentation/objectivec/1456712-objc_msgsend">"objc_msgSend - Objective-C Runtime"</a>. <i>Apple Developer Documentation</i><span class="reference-accessdate">. Retrieved <span class="nowrap">February 10,</span> 2020</span>.</cite></span>
</li>
<li id="cite_note-22"><span class="mw-cite-backlink"><b><a href="#cite_ref-22">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://gcc.gnu.org/onlinedocs/gcc/Messaging-with-the-GNU-Objective-C-runtime.html">"Messaging with the GNU Objective-C runtime"</a>. <i>Using the GNU Compiler Collection (GCC)</i><span class="reference-accessdate">. Retrieved <span class="nowrap">February 10,</span> 2020</span>.</cite></span>
</li>
<li id="cite_note-23"><span class="mw-cite-backlink"><b><a href="#cite_ref-23">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://developer.apple.com/library/archive/documentation/General/Conceptual/DevPedia-CocoaCore/Category.html">"Category"</a>. <i>Apple Developer (Cocoa Core Competencies)</i>.</cite></span>
</li>
<li id="cite_note-24"><span class="mw-cite-backlink"><b><a href="#cite_ref-24">^</a></b></span> <span class="reference-text"><cite id="CITEREFDalrympleKnaster2012" class="citation book cs1">Dalrymple, Mark; Knaster, Scott (June 27, 2012). <i>Learn Objective-C on the Mac</i>. Apress. p.&nbsp;9. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>9781430241881</bdi>. <q>The .m extension originally stood for "messages" when Objective-C was first introduced, referring to a central feature of Objective-C</q></cite></span>
</li>
<li id="cite_note-25"><span class="mw-cite-backlink"><b><a href="#cite_ref-25">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/ocrtForwarding.html#//apple_ref/doc/uid/TP40008048-CH105-SW1">"Objective-C Runtime Programming Guide"</a>. Apple Inc. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20140404193818/https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/ocrtForwarding.html#//apple_ref/doc/uid/TP40008048-CH105-SW1">Archived</a> from the original on April 4, 2014<span class="reference-accessdate">. Retrieved <span class="nowrap">October 21,</span> 2013</span>.</cite></span>
</li>
<li id="cite_note-26"><span class="mw-cite-backlink"><b><a href="#cite_ref-26">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://www.youtube.com/watch?v=JLPiMl8XUKU&amp;ab_channel=esugboard">"'The Smalltalk-80 Programming System' - ACM SIGGRAPH 1983 Issue 8"</a>. 21 December 2011<span class="reference-accessdate">. Retrieved <span class="nowrap">21 April</span> 2025</span> – via <a href="YouTube" title="YouTube">YouTube</a>.</cite>
Also <a rel="nofollow" class="external text" href="https://open-video.org/details.php?videoid=8206">available</a> at 'The Open Video Project'</span>
</li>
<li id="cite_note-27"><span class="mw-cite-backlink"><b><a href="#cite_ref-27">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://msdn.microsoft.com/en-us/library/bb383977.aspx">"Extension Methods (C# Programming Guide)"</a>. Microsoft. October 2010. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20110711201830/http://msdn.microsoft.com/en-us/library/bb383977.aspx">Archived</a> from the original on July 11, 2011<span class="reference-accessdate">. Retrieved <span class="nowrap">July 10,</span> 2011</span>.</cite></span>
</li>
<li id="cite_note-28"><span class="mw-cite-backlink"><b><a href="#cite_ref-28">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://learn.microsoft.com/en-us/cpp/preprocessor/hash-import-directive-cpp">"#import directive (C++)"</a>.</cite></span>
</li>
<li id="cite_note-29"><span class="mw-cite-backlink"><b><a href="#cite_ref-29">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://web.archive.org/web/20100905100849/http://developer.apple.com/mac/library/documentation/cocoa/conceptual/objectivec/Articles/ocCPlusPlus.html#//apple_ref/doc/uid/TP30001163-CH10-SW1">"Using C++ With Objective-C"</a>. <i>Mac OS X Reference Library</i>. Archived from <a rel="nofollow" class="external text" href="https://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/ObjectiveC/Articles/ocCPlusPlus.html#//apple_ref/doc/uid/TP30001163-CH10-SW1">the original</a> on September 5, 2010<span class="reference-accessdate">. Retrieved <span class="nowrap">February 12,</span> 2025</span>.</cite></span>
</li>
<li id="cite_note-30"><span class="mw-cite-backlink"><b><a href="#cite_ref-30">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://web.archive.org/web/20100905100849/http://developer.apple.com/mac/library/documentation/cocoa/conceptual/objectivec/Articles/ocCPlusPlus.html#//apple_ref/doc/uid/TP30001163-CH10-SW1">"Using C++ With Objective-C"</a>. <i>Mac OS X Reference Library</i>. Archived from <a rel="nofollow" class="external text" href="https://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/ObjectiveC/Articles/ocCPlusPlus.html#//apple_ref/doc/uid/TP30001163-CH10-SW1">the original</a> on September 5, 2010<span class="reference-accessdate">. Retrieved <span class="nowrap">February 10,</span> 2010</span>.</cite></span>
</li>
<li id="cite_note-31"><span class="mw-cite-backlink"><b><a href="#cite_ref-31">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://clang.llvm.org/docs/LanguageExtensions.html#interoperability-with-c-11-lambdas">"Clang Language Extensions — Clang 3.5 documentation"</a>. Clang.llvm.org. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20140224002333/http://clang.llvm.org/docs/LanguageExtensions.html#interoperability-with-c-11-lambdas">Archived</a> from the original on February 24, 2014<span class="reference-accessdate">. Retrieved <span class="nowrap">April 16,</span> 2014</span>.</cite></span>
</li>
<li id="cite_note-32"><span class="mw-cite-backlink"><b><a href="#cite_ref-32">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://web.archive.org/web/20090618184513/http://lists.apple.com/archives/Objc-language/2006/Aug/msg00039.html">"Objective-C 2.0: more clues"</a>. Lists.apple.com. August 10, 2006. Archived from <a rel="nofollow" class="external text" href="http://lists.apple.com/archives/Objc-language/2006/Aug/msg00039.html">the original</a> on June 18, 2009<span class="reference-accessdate">. Retrieved <span class="nowrap">May 30,</span> 2010</span>.</cite></span>
</li>
<li id="cite_note-33"><span class="mw-cite-backlink"><b><a href="#cite_ref-33">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://web.archive.org/web/20101124014332/http://lists.apple.com/archives/Objc-language/2006/Aug/msg00018.html">"Re: Objective-C 2.0"</a>. Lists.apple.com. Archived from <a rel="nofollow" class="external text" href="http://lists.apple.com/archives/Objc-language/2006/Aug/msg00018.html">the original</a> on November 24, 2010<span class="reference-accessdate">. Retrieved <span class="nowrap">May 30,</span> 2010</span>.</cite></span>
</li>
<li id="cite_note-gcc46-34"><span class="mw-cite-backlink">^ <a href="#cite_ref-gcc46_34-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-gcc46_34-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://gcc.gnu.org/gcc-4.6/changes.html">"GCC 4.6 Release Series — Changes, New Features, and Fixes&nbsp;: GNU Project&nbsp;: Free Software Foundation"</a>. <i>Gcc.gnu.org</i>. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20180105084039/http://gcc.gnu.org/gcc-4.6/changes.html">Archived</a> from the original on January 5, 2018<span class="reference-accessdate">. Retrieved <span class="nowrap">December 24,</span> 2017</span>.</cite></span>
</li>
<li id="cite_note-objc2-faq-35"><span class="mw-cite-backlink">^ <a href="#cite_ref-objc2-faq_35-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-objc2-faq_35-1"><sup><i><b>b</b></i></sup></a> <a href="#cite_ref-objc2-faq_35-2"><sup><i><b>c</b></i></sup></a> <a href="#cite_ref-objc2-faq_35-3"><sup><i><b>d</b></i></sup></a></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://wiki.gnustep.org/index.php/ObjC2_FAQ">"ObjC2 FAQ"</a>. <i>GNUstep</i><span class="reference-accessdate">. Retrieved <span class="nowrap">January 6,</span> 2020</span>.</cite></span>
</li>
<li id="cite_note-36"><span class="mw-cite-backlink"><b><a href="#cite_ref-36">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://opensource.apple.com/source/objc4/objc4-756.2/">"Source Browser: objc4, 756.2"</a>. <i>Apple Open Source</i><span class="reference-accessdate">. Retrieved <span class="nowrap">January 6,</span> 2020</span>.</cite></span>
</li>
<li id="cite_note-37"><span class="mw-cite-backlink"><b><a href="#cite_ref-37">^</a></b></span> <span class="reference-text"><a rel="nofollow" class="external text" href="https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/GarbageCollection/Articles/gcAPI.html">Garbage Collection Programming Guide: Garbage Collection API</a> <a rel="nofollow" class="external text" href="https://web.archive.org/web/20120609170929/http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/GarbageCollection/Articles/gcAPI.html">Archived</a> June 9, 2012, at the <a href="Wayback_Machine" title="Wayback Machine">Wayback Machine</a> (Apple developer website - search for "__strong")</span>
</li>
<li id="cite_note-38"><span class="mw-cite-backlink"><b><a href="#cite_ref-38">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/GarbageCollection/Introduction.html">"Garbage Collection Programming Guide: Introduction to Garbage Collection"</a>. Apple Inc. October 3, 2011. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20120609170929/http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/GarbageCollection/Introduction.html">Archived</a> from the original on June 9, 2012<span class="reference-accessdate">. Retrieved <span class="nowrap">December 23,</span> 2011</span>.</cite></span>
</li>
<li id="cite_note-39"><span class="mw-cite-backlink"><b><a href="#cite_ref-39">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://web.archive.org/web/20100724195423/http://developer.apple.com/leopard/overview/objectivec2.html">"Leopard Technology Series for Developers: Objective-C 2.0 Overview"</a>. Apple Inc. November 6, 2007. Archived from <a rel="nofollow" class="external text" href="https://developer.apple.com/leopard/overview/objectivec2.html">the original</a> on July 24, 2010<span class="reference-accessdate">. Retrieved <span class="nowrap">May 30,</span> 2010</span>.</cite></span>
</li>
<li id="cite_note-40"><span class="mw-cite-backlink"><b><a href="#cite_ref-40">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://developer.apple.com/library/mac/#releasenotes/ObjectiveC/RN-TransitioningToARC/Introduction/Introduction.html">"Transitioning to ARC Release Notes"</a>. Apple Inc. July 17, 2012. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20120609170929/http://developer.apple.com/library/mac/#releasenotes/ObjectiveC/RN-TransitioningToARC/Introduction/Introduction.html">Archived</a> from the original on June 9, 2012<span class="reference-accessdate">. Retrieved <span class="nowrap">August 26,</span> 2012</span>.</cite></span>
</li>
<li id="cite_note-41"><span class="mw-cite-backlink"><b><a href="#cite_ref-41">^</a></b></span> <span class="reference-text"><cite id="CITEREFMike_Ash" class="citation web cs1">Mike Ash. <a rel="nofollow" class="external text" href="https://www.mikeash.com/pyblog/friday-qa-2013-09-27-arm64-and-you.html">"Friday Q&amp;A 2013-09-27: ARM64 and You"</a>. mikeash.com. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20140426201454/https://www.mikeash.com/pyblog/friday-qa-2013-09-27-arm64-and-you.html">Archived</a> from the original on April 26, 2014<span class="reference-accessdate">. Retrieved <span class="nowrap">April 27,</span> 2014</span>.</cite></span>
</li>
<li id="cite_note-42"><span class="mw-cite-backlink"><b><a href="#cite_ref-42">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://www.sealiesoftware.com/blog/archive/2013/09/24/objc_explain_Non-pointer_isa.html">"Hamster Emporium: [objc explain]: Non-pointer isa"</a>. Sealiesoftware.com. September 24, 2013. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20140603110517/http://www.sealiesoftware.com/blog/archive/2013/09/24/objc_explain_Non-pointer_isa.html">Archived</a> from the original on June 3, 2014<span class="reference-accessdate">. Retrieved <span class="nowrap">April 27,</span> 2014</span>.</cite></span>
</li>
<li id="cite_note-43"><span class="mw-cite-backlink"><b><a href="#cite_ref-43">^</a></b></span> <span class="reference-text"><cite id="CITEREFApple,_Inc.2009" class="citation web cs1">Apple, Inc. (2009). <a rel="nofollow" class="external text" href="https://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/ObjectiveC/Articles/ocFastEnumeration.html">"Fast Enumeration"</a>. apple.com. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20091217202149/http://developer.apple.com/mac/library/DOCUMENTATION/Cocoa/Conceptual/ObjectiveC/Articles/ocFastEnumeration.html">Archived</a> from the original on December 17, 2009<span class="reference-accessdate">. Retrieved <span class="nowrap">December 31,</span> 2009</span>.</cite></span>
</li>
<li id="cite_note-44"><span class="mw-cite-backlink"><b><a href="#cite_ref-44">^</a></b></span> <span class="reference-text"><cite id="CITEREFFree_Software_Foundation,_Inc.2011" class="citation web cs1">Free Software Foundation, Inc. (2011). <a rel="nofollow" class="external text" href="https://gcc.gnu.org/gcc-4.6/changes.html">"GCC 4.6 Release Series – Changes, New Features, and Fixes"</a>. <i>Gcc.gnu.org</i>. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20131202234354/http://gcc.gnu.org/gcc-4.6/changes.html">Archived</a> from the original on December 2, 2013<span class="reference-accessdate">. Retrieved <span class="nowrap">November 27,</span> 2013</span>.</cite></span>
</li>
<li id="cite_note-Blocks_requirements-45"><span class="mw-cite-backlink"><b><a href="#cite_ref-Blocks_requirements_45-0">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Blocks/Articles/00_Introduction.html">"Blocks Programming Topics – Mac Developer Library"</a>. Apple Inc. March 8, 2011. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20120609170929/http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Blocks/Articles/00_Introduction.html">Archived</a> from the original on June 9, 2012<span class="reference-accessdate">. Retrieved <span class="nowrap">November 28,</span> 2012</span>.</cite></span>
</li>
<li id="cite_note-llvm-ver-46"><span class="mw-cite-backlink">^ <a href="#cite_ref-llvm-ver_46-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-llvm-ver_46-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://clang.llvm.org/docs/AutomaticReferenceCounting.html">"Objective-C Automatic Reference Counting (ARC) — Clang 11 documentation"</a>. <i>Clang documentation</i><span class="reference-accessdate">. Retrieved <span class="nowrap">February 20,</span> 2020</span>. <q>For now, it is sensible to version this document by the releases of its sole implementation (and its host project), clang. "LLVM X.Y" refers to an open-source release of clang from the LLVM project. "Apple X.Y" refers to an Apple-provided release of the Apple LLVM Compiler.</q></cite></span>
</li>
<li id="cite_note-Transitioning_to_ARC-47"><span class="mw-cite-backlink"><b><a href="#cite_ref-Transitioning_to_ARC_47-0">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://developer.apple.com/library/ios/#releasenotes/ObjectiveC/RN-TransitioningToARC/Introduction/Introduction.html">"Transitioning to ARC"</a>. Apple Inc. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20110907013839/http://developer.apple.com/library/iOS/#releasenotes/ObjectiveC/RN-TransitioningToARC/Introduction/Introduction.html">Archived</a> from the original on September 7, 2011<span class="reference-accessdate">. Retrieved <span class="nowrap">October 8,</span> 2012</span>.</cite></span>
</li>
<li id="cite_note-48"><span class="mw-cite-backlink"><b><a href="#cite_ref-48">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://releases.llvm.org/3.0/docs/ReleaseNotes.html">"LLVM 3.0 Release Notes"</a>. <i>releases.llvm.org</i>.</cite></span>
</li>
<li id="cite_note-Programming_with_Obj-C_–_Values_and_Collections-49"><span class="mw-cite-backlink">^ <a href="#cite_ref-Programming_with_Obj-C_–_Values_and_Collections_49-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-Programming_with_Obj-C_–_Values_and_Collections_49-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/FoundationTypesandCollections/FoundationTypesandCollections.html">"Programming with Objective-C: Values and Collections"</a>. Apple Inc. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20110907013839/http://developer.apple.com/library/iOS/#documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/FoundationTypesandCollections/FoundationTypesandCollections.html">Archived</a> from the original on September 7, 2011<span class="reference-accessdate">. Retrieved <span class="nowrap">October 8,</span> 2012</span>.</cite></span>
</li>
<li id="cite_note-llvm31-50"><span class="mw-cite-backlink"><b><a href="#cite_ref-llvm31_50-0">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://releases.llvm.org/3.1/tools/clang/docs/ReleaseNotes.html">"Clang 3.1 Release Notes"</a>. <i>releases.llvm.org</i>.</cite></span>
</li>
<li id="cite_note-51"><span class="mw-cite-backlink"><b><a href="#cite_ref-51">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://web.archive.org/web/20250217134455/https://gist.github.com/yamaya/2924292#file-xcode-clang-vers-L389">"@yamaya's GitHub Gist documenting the 'Xcode clang version record'"</a>. Archived from <a rel="nofollow" class="external text" href="https://gist.github.com/yamaya/2924292#file-xcode-clang-vers-L389">the original</a> on February 17, 2025<span class="reference-accessdate">. Retrieved <span class="nowrap">February 17,</span> 2025</span>.</cite></span>
</li>
<li id="cite_note-52"><span class="mw-cite-backlink"><b><a href="#cite_ref-52">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://web.archive.org/web/20250217134923/https://developer.apple.com/documentation/xcode-release-notes/xcode-13-release-notes#New-Features">"Xcode 13 Release Notes &gt; Apple Clang Compiler &gt; New Features"</a>. Archived from <a rel="nofollow" class="external text" href="https://developer.apple.com/documentation/xcode-release-notes/xcode-13-release-notes#New-Features">the original</a> on February 17, 2025<span class="reference-accessdate">. Retrieved <span class="nowrap">February 17,</span> 2025</span>.</cite></span>
</li>
<li id="cite_note-ObjCLiterals-53"><span class="mw-cite-backlink"><b><a href="#cite_ref-ObjCLiterals_53-0">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://clang.llvm.org/docs/ObjectiveCLiterals.html">"Objective-C Literals — Clang 3.5 documentation"</a>. Clang.llvm.org. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20140606050836/http://clang.llvm.org/docs/ObjectiveCLiterals.html">Archived</a> from the original on June 6, 2014<span class="reference-accessdate">. Retrieved <span class="nowrap">April 16,</span> 2014</span>.</cite></span>
</li>
<li id="cite_note-54"><span class="mw-cite-backlink"><b><a href="#cite_ref-54">^</a></b></span> <span class="reference-text"><cite class="citation cs2"><i>Rhapsody Developer's Guide</i>, AP Professional, 1997, pp.&nbsp;<span class="nowrap">76–</span>84</cite></span>
</li>
<li id="cite_note-55"><span class="mw-cite-backlink"><b><a href="#cite_ref-55">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://users.pandora.be/stes/compiler.html">"Portable Object Compiler"</a>. Users.pandora.be. January 1, 1970. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20080802040731/http://users.pandora.be/stes/compiler.html">Archived</a> from the original on August 2, 2008<span class="reference-accessdate">. Retrieved <span class="nowrap">May 30,</span> 2010</span>.</cite></span>
</li>
<li id="cite_note-56"><span class="mw-cite-backlink"><b><a href="#cite_ref-56">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://web.archive.org/web/20110727185136/http://www.breadbox.com/downloads.asp?id=54&amp;category=GeosSDK&amp;maincategory=SDK">"Breadbox Computer Company LLC homepage"</a>. Archived from <a rel="nofollow" class="external text" href="http://www.breadbox.com/downloads.asp?id=54&amp;category=GeosSDK&amp;maincategory=SDK">the original</a> on July 27, 2011<span class="reference-accessdate">. Retrieved <span class="nowrap">December 8,</span> 2010</span>.</cite></span>
</li>
<li id="cite_note-57"><span class="mw-cite-backlink"><b><a href="#cite_ref-57">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://github.com/gcc-mirror/gcc/tree/master/libobjc">"gcc/libobjc"</a>. <i>GitHub</i>. gcc-mirror. January 6, 2020<span class="reference-accessdate">. Retrieved <span class="nowrap">January 6,</span> 2020</span>. <q>he runtime has been completely rewritten in gcc 2.4. The earlier runtime had several severe bugs and was rather incomplete.</q></cite></span>
</li>
<li id="cite_note-58"><span class="mw-cite-backlink"><b><a href="#cite_ref-58">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://gcc.gnu.org/onlinedocs/gcc-6.3.0/gcc/GNU-Objective-C-runtime-API.html">"GNU Objective-C runtime API"</a>. <i>Using GCC</i><span class="reference-accessdate">. Retrieved <span class="nowrap">January 6,</span> 2020</span>.</cite></span>
</li>
<li id="cite_note-59"><span class="mw-cite-backlink"><b><a href="#cite_ref-59">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://github.com/Microsoft/WinObjC">"WinObjC on GitHub"</a>. <i><a href="GitHub" title="GitHub">GitHub</a></i>. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20171202223021/https://github.com/Microsoft/WinObjC/">Archived</a> from the original on December 2, 2017<span class="reference-accessdate">. Retrieved <span class="nowrap">February 13,</span> 2018</span>.</cite></span>
</li>
<li id="cite_note-60"><span class="mw-cite-backlink"><b><a href="#cite_ref-60">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://www.gnustep.org/windows/installer.html">"GNUStep Installer"</a>. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20180217174757/http://www.gnustep.org/windows/installer.html">Archived</a> from the original on February 17, 2018<span class="reference-accessdate">. Retrieved <span class="nowrap">February 14,</span> 2018</span>.</cite></span>
</li>
<li id="cite_note-61"><span class="mw-cite-backlink"><b><a href="#cite_ref-61">^</a></b></span> <span class="reference-text"><cite id="CITEREFApple,_Inc.2006" class="citation web cs1">Apple, Inc. (August 22, 2006). <a rel="nofollow" class="external text" href="https://web.archive.org/web/20071024144921/http://www.apple.com/macosx/developertools/xcode.html">"Mac OS X Leopard – Xcode 3.0"</a>. apple.com. Archived from <a rel="nofollow" class="external text" href="https://www.apple.com/macosx/developertools/xcode.html">the original</a> on October 24, 2007<span class="reference-accessdate">. Retrieved <span class="nowrap">August 22,</span> 2006</span>.</cite></span>
</li>
<li id="cite_note-62"><span class="mw-cite-backlink"><b><a href="#cite_ref-62">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://developer.apple.com/library/ios/#releasenotes/ObjectiveC/RN-TransitioningToARC/Introduction/Introduction.html">"Transitioning to ARC Release Notes"</a>. <i>iOS Developer Library</i>. Developer.apple.com. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20110907013839/http://developer.apple.com/library/iOS/#releasenotes/ObjectiveC/RN-TransitioningToARC/Introduction/Introduction.html">Archived</a> from the original on September 7, 2011<span class="reference-accessdate">. Retrieved <span class="nowrap">April 16,</span> 2014</span>.</cite></span>
</li>
</ol></div></div>
<div class="mw-heading mw-heading2"><h2 id="Further_reading">Further reading</h2></div>
<style data-mw-deduplicate="TemplateStyles:r1239549316">
/* start https://en.wikipedia.org/ */


.mw-parser-output .refbegin{margin-bottom:0.5em}.mw-parser-output .refbegin-hanging-indents>ul{margin-left:0}.mw-parser-output .refbegin-hanging-indents>ul>li{margin-left:0;padding-left:3.2em;text-indent:-3.2em}.mw-parser-output .refbegin-hanging-indents ul,.mw-parser-output .refbegin-hanging-indents ul li{list-style:none}@media(max-width:720px){.mw-parser-output .refbegin-hanging-indents>ul>li{padding-left:1.6em;text-indent:-1.6em}}.mw-parser-output .refbegin-columns{margin-top:0.3em}.mw-parser-output .refbegin-columns ul{margin-top:0}.mw-parser-output .refbegin-columns li{page-break-inside:avoid;break-inside:avoid-column}@media screen{.mw-parser-output .refbegin{font-size:90%}}


/* end https://en.wikipedia.org/ */
</style><div class="refbegin" style="">
<ul><li><cite id="CITEREFCox1991" class="citation book cs1">Cox, Brad J. (1991). <i>Object Oriented Programming: An Evolutionary Approach</i>. Addison Wesley. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>0-201-54834-8</bdi>.</cite></li></ul>
</div>
<div class="mw-heading mw-heading2"><h2 id="External_links">External links</h2></div>
<style data-mw-deduplicate="TemplateStyles:r1290876196">
/* start https://en.wikipedia.org/ */


.mw-parser-output .side-box{margin:4px 0;box-sizing:border-box;border:1px solid #aaa;font-size:88%;line-height:1.25em;background-color:var(--background-color-interactive-subtle,#f8f9fa);display:flow-root}.mw-parser-output .infobox .side-box{font-size:100%}.mw-parser-output .side-box-abovebelow,.mw-parser-output .side-box-text{padding:0.25em 0.9em}.mw-parser-output .side-box-image{padding:2px 0 2px 0.9em;text-align:center}.mw-parser-output .side-box-imageright{padding:2px 0.9em 2px 0;text-align:center}@media(min-width:500px){.mw-parser-output .side-box-flex{display:flex;align-items:center}.mw-parser-output .side-box-text{flex:1;min-width:0}}@media(min-width:720px){.mw-parser-output .side-box{width:238px}.mw-parser-output .side-box-right{clear:right;float:right;margin-left:1em}.mw-parser-output .side-box-left{margin-right:1em}}


/* end https://en.wikipedia.org/ */
</style><style data-mw-deduplicate="TemplateStyles:r1237033735">
/* start https://en.wikipedia.org/ */


@media print{body.ns-0 .mw-parser-output .sistersitebox{display:none!important}}@media screen{html.skin-theme-clientpref-night .mw-parser-output .sistersitebox img[src*="Wiktionary-logo-en-v2.svg"]{background-color:white}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .sistersitebox img[src*="Wiktionary-logo-en-v2.svg"]{background-color:white}}


/* end https://en.wikipedia.org/ */
</style><div class="side-box side-box-right sistersitebox"><style data-mw-deduplicate="TemplateStyles:r1126788409">
/* start https://en.wikipedia.org/ */


.mw-parser-output .plainlist ol,.mw-parser-output .plainlist ul{line-height:inherit;list-style:none;margin:0;padding:0}.mw-parser-output .plainlist ol li,.mw-parser-output .plainlist ul li{margin-bottom:0}


/* end https://en.wikipedia.org/ */
</style>
<div class="side-box-flex">
<div class="side-box-image"><span class="noviewer" typeof="mw:File"></span></div>
<div class="side-box-text plainlist">Wikibooks has a book on the topic of: <i><b><a href="https://en.wikibooks.org/wiki/Objective-C_Programming" class="extiw external" title="wikibooks:Objective-C Programming">Objective-C Programming</a></b></i></div></div>
</div>
<ul><li><a rel="nofollow" class="external text" href="https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/">Programming with Objective-C</a>, from Apple (2012-12-13)</li>
<li><i><a rel="nofollow" class="external text" href="https://developer.apple.com/legacy/library/documentation/Cocoa/Conceptual/ObjectiveC/Introduction/introObjectiveC.html">The Objective-C Programming Language</a></i>, from Apple (2011-10-11)</li>
<li><i><a rel="nofollow" class="external text" href="https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Introduction/Introduction.html">Objective-C Runtime Programming Guide</a></i>, from Apple (2009-10-19)</li>
<li><a rel="nofollow" class="external text" href="https://www.gnu.org/software/gnustep/resources/documentation/Developer/Base/ProgrammingManual/manual_toc.html">Objective-C GNUstep Base Programming Manual</a></li>
<li><a rel="nofollow" class="external text" href="https://web.archive.org/web/20120204044211/http://virtualschool.edu/objectivec/">Objective-C by Brad Cox</a></li>
<li><a rel="nofollow" class="external text" href="http://www.faqs.org/faqs/computer-lang/Objective-C/faq/">Objective-C FAQ</a></li>
<li><a rel="nofollow" class="external text" href="https://iosexamples.com/">Objective-C Example</a> (<a rel="nofollow" class="external text" href="https://web.archive.org/web/20240423151501/https://iosexamples.com/">Archived</a> April 23, 2024, at the <a href="Wayback_Machine" title="Wayback Machine">Wayback Machine</a>)</li></ul>
<div class="navbox-styles"><style data-mw-deduplicate="TemplateStyles:r1236075235">
/* start https://en.wikipedia.org/ */


.mw-parser-output .navbox{box-sizing:border-box;border:1px solid #a2a9b1;width:100%;clear:both;font-size:88%;text-align:center;padding:1px;margin:1em auto 0}.mw-parser-output .navbox .navbox{margin-top:0}.mw-parser-output .navbox+.navbox,.mw-parser-output .navbox+.navbox-styles+.navbox{margin-top:-1px}.mw-parser-output .navbox-inner,.mw-parser-output .navbox-subgroup{width:100%}.mw-parser-output .navbox-group,.mw-parser-output .navbox-title,.mw-parser-output .navbox-abovebelow{padding:0.25em 1em;line-height:1.5em;text-align:center}.mw-parser-output .navbox-group{white-space:nowrap;text-align:right}.mw-parser-output .navbox,.mw-parser-output .navbox-subgroup{background-color:#fdfdfd}.mw-parser-output .navbox-list{line-height:1.5em;border-color:#fdfdfd}.mw-parser-output .navbox-list-with-group{text-align:left;border-left-width:2px;border-left-style:solid}.mw-parser-output tr+tr>.navbox-abovebelow,.mw-parser-output tr+tr>.navbox-group,.mw-parser-output tr+tr>.navbox-image,.mw-parser-output tr+tr>.navbox-list{border-top:2px solid #fdfdfd}.mw-parser-output .navbox-title{background-color:#ccf}.mw-parser-output .navbox-abovebelow,.mw-parser-output .navbox-group,.mw-parser-output .navbox-subgroup .navbox-title{background-color:#ddf}.mw-parser-output .navbox-subgroup .navbox-group,.mw-parser-output .navbox-subgroup .navbox-abovebelow{background-color:#e6e6ff}.mw-parser-output .navbox-even{background-color:#f7f7f7}.mw-parser-output .navbox-odd{background-color:transparent}.mw-parser-output .navbox .hlist td dl,.mw-parser-output .navbox .hlist td ol,.mw-parser-output .navbox .hlist td ul,.mw-parser-output .navbox td.hlist dl,.mw-parser-output .navbox td.hlist ol,.mw-parser-output .navbox td.hlist ul{padding:0.125em 0}.mw-parser-output .navbox .navbar{display:block;font-size:100%}.mw-parser-output .navbox-title .navbar{float:left;text-align:left;margin-right:0.5em}body.skin--responsive .mw-parser-output .navbox-image img{max-width:none!important}@media print{body.ns-0 .mw-parser-output .navbox{display:none!important}}


/* end https://en.wikipedia.org/ */
</style></div><div role="navigation" class="navbox" aria-labelledby="Programming_languages625" style="padding:3px"><table class="nowraplinks hlist mw-collapsible expanded navbox-inner" style="border-spacing:0;background:transparent;color:inherit"><tbody><tr><th scope="col" class="navbox-title" colspan="2"><style data-mw-deduplicate="TemplateStyles:r1239400231">
/* start https://en.wikipedia.org/ */


.mw-parser-output .navbar{display:inline;font-size:88%;font-weight:normal}.mw-parser-output .navbar-collapse{float:left;text-align:left}.mw-parser-output .navbar-boxtext{word-spacing:0}.mw-parser-output .navbar ul{display:inline-block;white-space:nowrap;line-height:inherit}.mw-parser-output .navbar-brackets::before{margin-right:-0.125em;content:"[ "}.mw-parser-output .navbar-brackets::after{margin-left:-0.125em;content:" ]"}.mw-parser-output .navbar li{word-spacing:-0.125em}.mw-parser-output .navbar a>span,.mw-parser-output .navbar a>abbr{text-decoration:inherit}.mw-parser-output .navbar-mini abbr{font-variant:small-caps;border-bottom:none;text-decoration:none;cursor:inherit}.mw-parser-output .navbar-ct-full{font-size:114%;margin:0 7em}.mw-parser-output .navbar-ct-mini{font-size:114%;margin:0 4em}html.skin-theme-clientpref-night .mw-parser-output .navbar li a abbr{color:var(--color-base)!important}@media(prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .navbar li a abbr{color:var(--color-base)!important}}@media print{.mw-parser-output .navbar{display:none!important}}


/* end https://en.wikipedia.org/ */
</style><div id="Programming_languages625" style="font-size:114%;margin:0 4em"><a href="Programming_language" title="Programming language">Programming languages</a></div></th></tr><tr><td class="navbox-abovebelow" colspan="2"><div>
<ul><li><a href="Comparison_of_programming_languages" title="Comparison of programming languages">Comparison</a></li>
<li><a href="Timeline_of_programming_languages" title="Timeline of programming languages">Timeline</a></li>
<li><a href="History_of_programming_languages" title="History of programming languages">History</a></li></ul>
</div></td></tr><tr><td colspan="2" class="navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Ada_(programming_language)" title="Ada (programming language)">Ada</a></li>
<li><a href="ALGOL" title="ALGOL">ALGOL</a>
<ul><li><a href="Simula" title="Simula">Simula</a></li></ul></li>
<li><a href="APL_(programming_language)" title="APL (programming language)">APL</a></li>
<li><a href="Assembly_language" title="Assembly language">Assembly</a></li>
<li><a href="BASIC" title="BASIC">BASIC</a>
<ul><li><a href="Visual_Basic" title="Visual Basic">Visual Basic</a>
<ul><li><a href="Visual_Basic_(classic)" title="Visual Basic (classic)">classic</a></li>
<li><a href="Visual_Basic_(.NET)" title="Visual Basic (.NET)">.NET</a></li></ul></li></ul></li>
<li><a href="C_(programming_language)" title="C (programming language)">C</a></li>
<li><a href="C%2B%2B" title="C++">C++</a></li>
<li><a href="C_Sharp_(programming_language)" title="C Sharp (programming language)">C#</a></li>
<li><a href="COBOL" title="COBOL">COBOL</a></li>
<li><a href="Erlang_(programming_language)" title="Erlang (programming language)">Erlang</a>
<ul><li><a href="Elixir_(programming_language)" title="Elixir (programming language)">Elixir</a></li></ul></li>
<li><a href="Forth_(programming_language)" title="Forth (programming language)">Forth</a></li>
<li><a href="Fortran" title="Fortran">Fortran</a></li>
<li><a href="Go_(programming_language)" title="Go (programming language)">Go</a></li>
<li><a href="Haskell" title="Haskell">Haskell</a></li>
<li><a href="Java_(programming_language)" title="Java (programming language)">Java</a></li>
<li><a href="JavaScript" title="JavaScript">JavaScript</a></li>
<li><a href="Julia_(programming_language)" title="Julia (programming language)">Julia</a></li>
<li><a href="Kotlin_(programming_language)" title="Kotlin (programming language)">Kotlin</a></li>
<li><a href="Lisp_(programming_language)" title="Lisp (programming language)">Lisp</a></li>
<li><a href="Lua" title="Lua">Lua</a></li>
<li><a href="MATLAB" title="MATLAB">MATLAB</a></li>
<li><a href="ML_(programming_language)" title="ML (programming language)">ML</a>
<ul><li><a href="Caml" title="Caml">Caml </a>
<ul><li><a href="OCaml" title="OCaml">OCaml</a></li></ul></li></ul></li>
<li><a href="Pascal_(programming_language)" title="Pascal (programming language)">Pascal</a>
<ul><li><a href="Object_Pascal" title="Object Pascal">Object Pascal</a></li></ul></li>
<li><a href="Perl" title="Perl">Perl </a>
<ul><li><a href="Raku_(programming_language)" title="Raku (programming language)">Raku</a></li></ul></li>
<li><a href="PHP" title="PHP">PHP</a></li>
<li><a href="Prolog" title="Prolog">Prolog</a></li>
<li><a href="Python_(programming_language)" title="Python (programming language)">Python</a></li>
<li><a href="R_(programming_language)" title="R (programming language)">R</a></li>
<li><a href="Ruby_(programming_language)" title="Ruby (programming language)">Ruby</a></li>
<li><a href="Rust_(programming_language)" title="Rust (programming language)">Rust</a></li>
<li><a href="SAS_language" title="SAS language">SAS</a></li>
<li><a href="SQL" title="SQL">SQL</a></li>
<li><a href="Scratch_(programming_language)" title="Scratch (programming language)">Scratch</a></li>
<li><a href="Shell_script" title="Shell script">Shell</a></li>
<li><a href="Smalltalk" title="Smalltalk">Smalltalk</a></li>
<li><a href="Swift_(programming_language)" title="Swift (programming language)">Swift</a></li>
<li><i><a href="List_of_programming_languages" title="List of programming languages">more...</a></i></li></ul>
</div></td></tr><tr><td class="navbox-abovebelow" colspan="2"><div>
<ul><li><span class="noviewer" typeof="mw:File"><span title="List-Class article"></span></span> <b>Lists:</b> <a href="List_of_programming_languages" title="List of programming languages">Alphabetical</a></li>
<li><a href="List_of_programming_languages_by_type" title="List of programming languages by type">Categorical</a></li>
<li><a href="Generational_list_of_programming_languages" title="Generational list of programming languages">Generational</a></li>
<li><a href="Non-English-based_programming_languages" title="Non-English-based programming languages">Non-English-based</a></li>
<li><span class="noviewer" typeof="mw:File"><span title="Category"></span></span> Category</li></ul>
</div></td></tr></tbody></table></div>
<div class="navbox-styles"></div><div role="navigation" class="navbox" aria-labelledby="C_programming_language527" style="padding:3px"><table class="nowraplinks hlist mw-collapsible autocollapse navbox-inner" style="border-spacing:0;background:transparent;color:inherit"><tbody><tr><th scope="col" class="navbox-title" colspan="2"><div id="C_programming_language527" style="font-size:114%;margin:0 4em"><a href="C_(programming_language)" title="C (programming language)">C programming language</a></div></th></tr><tr><td class="navbox-abovebelow" colspan="2"><div>
<ul><li><a href="ANSI_C" title="ANSI C">ANSI C</a></li>
<li><a href="C99" title="C99">C99</a></li>
<li><a href="C11_(C_standard_revision)" title="C11 (C standard revision)">C11</a></li>
<li><a href="C17_(C_standard_revision)" title="C17 (C standard revision)">C17</a></li>
<li><a href="C23_(C_standard_revision)" title="C23 (C standard revision)">C23</a></li>
<li><a href="Embedded_C" title="Embedded C">Embedded C</a></li>
<li><a href="MISRA_C" title="MISRA C">MISRA C</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%">Features</th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Subroutine" class="mw-redirect" title="Subroutine">Functions</a></li>
<li><a href="Include_directive#C" title="Include directive">Header files</a></li>
<li><a href="Operators_in_C_and_C%2B%2B" title="Operators in C and C++">Operators</a></li>
<li><a href="C_string_handling" title="C string handling">String</a></li>
<li><a href="C_syntax" title="C syntax">Syntax</a></li>
<li><a href="C_preprocessor" title="C preprocessor">Preprocessor</a></li>
<li><a href="C_data_types" title="C data types">Data types</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="C_standard_library" title="C standard library">Standard library</a></th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em"></div><table class="nowraplinks navbox-subgroup" style="border-spacing:0"><tbody><tr><td colspan="2" class="navbox-list navbox-even" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="C_character_classification" title="C character classification">Char</a></li>
<li><a href="C_file_input/output" title="C file input/output">File I/O</a></li>
<li><a href="C_mathematical_functions" title="C mathematical functions">Math</a></li>
<li><a href="C_dynamic_memory_allocation" title="C dynamic memory allocation">Dynamic memory</a></li>
<li><a href="C_string_handling" title="C string handling">String</a></li>
<li><a href="C_date_and_time_functions" title="C date and time functions">Time</a></li>
<li><a href="Stdarg.h" title="Stdarg.h">Variadic</a></li>
<li><a href="C_POSIX_library" title="C POSIX library">POSIX</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%">Implementations</th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Bionic_(software)" title="Bionic (software)">Bionic</a>
<ul><li><a href="Hybris_(software)" class="mw-redirect" title="Hybris (software)">libhybris</a></li></ul></li>
<li><a href="Dietlibc" title="Dietlibc">dietlibc</a></li>
<li><a href="Glibc" title="Glibc">glibc</a>
<ul><li><a href="Embedded_GLIBC" class="mw-redirect" title="Embedded GLIBC">EGLIBC</a></li></ul></li>
<li><a href="Klibc" title="Klibc">klibc</a></li>
<li><a href="Microsoft_Windows_library_files" title="Microsoft Windows library files">Windows CRT</a></li>
<li><a href="Musl" title="Musl">musl</a></li>
<li><a href="Newlib" title="Newlib">Newlib</a></li>
<li><a href="UClibc" title="UClibc">uClibc</a></li></ul>
</div></td></tr></tbody></table><div></div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="List_of_C_compilers" class="mw-redirect" title="List of C compilers">Compilers</a></th><td class="navbox-list-with-group navbox-list navbox-even" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Amsterdam_Compiler_Kit" title="Amsterdam Compiler Kit">ACK</a></li>
<li><a href="Borland_Turbo_C" class="mw-redirect" title="Borland Turbo C">Borland Turbo C</a></li>
<li><a href="Clang" title="Clang">Clang</a></li>
<li><a href="GNU_Compiler_Collection" title="GNU Compiler Collection">GCC</a></li>
<li><a href="Intel_C%2B%2B_Compiler" title="Intel C++ Compiler">ICC</a></li>
<li><a href="LCC_(compiler)" title="LCC (compiler)">LCC</a></li>
<li><a href="Norcroft_C_compiler" title="Norcroft C compiler">Norcroft C</a></li>
<li><a href="Portable_C_Compiler" title="Portable C Compiler">PCC</a></li>
<li><a href="Small_Device_C_Compiler" title="Small Device C Compiler">SDCC</a></li>
<li><a href="Tiny_C_Compiler" title="Tiny C Compiler">TCC</a></li>
<li><a href="Microsoft_Visual_C%2B%2B" title="Microsoft Visual C++">Visual C++ (MSVC)</a></li>
<li><a href="Watcom_C/C%2B%2B" title="Watcom C/C++">Watcom C/C++</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Integrated_development_environment" title="Integrated development environment">IDEs</a></th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Anjuta" title="Anjuta">Anjuta</a></li>
<li><a href="CLion" class="mw-redirect" title="CLion">CLion</a></li>
<li><a href="Code%3A%3ABlocks" title="Code::Blocks">Code::Blocks</a></li>
<li><a href="CodeLite" title="CodeLite">CodeLite</a></li>
<li><a href="Eclipse_(software)" title="Eclipse (software)">Eclipse</a></li>
<li><a href="Geany" title="Geany">Geany</a></li>
<li><a href="GNOME_Builder" title="GNOME Builder">GNOME Builder</a></li>
<li><a href="KDevelop" title="KDevelop">KDevelop</a></li>
<li><a href="NetBeans" title="NetBeans">NetBeans</a></li>
<li><a href="Visual_Studio" title="Visual Studio">Visual Studio</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%">Comparison with<br>other languages</th><td class="navbox-list-with-group navbox-list navbox-even" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Compatibility_of_C_and_C%2B%2B" title="Compatibility of C and C++">Compatibility of C and C++</a></li>
<li><a href="Comparison_of_Pascal_and_C" title="Comparison of Pascal and C">Comparison with Pascal</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%">Descendant<br>languages</th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Alef_(programming_language)" title="Alef (programming language)">Alef</a></li>
<li><a href="C%2B%2B" title="C++">C++</a></li>
<li><a href="C_Sharp_(programming_language)" title="C Sharp (programming language)">C#</a></li>
<li><a href="D_(programming_language)" title="D (programming language)">D</a></li>

<li><a href="Go_(programming_language)" title="Go (programming language)">Go</a></li>
<li><a href="Vala_(programming_language)" title="Vala (programming language)">Vala</a></li>
<li><a href="Zig_(programming_language)" title="Zig (programming language)">Zig</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%">Designer</th><td class="navbox-list-with-group navbox-list navbox-even" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Dennis_Ritchie" title="Dennis Ritchie">Dennis Ritchie</a></li></ul>
</div></td></tr><tr><td class="navbox-abovebelow" colspan="2"><div>
<ul><li><span class="noviewer" typeof="mw:File"><span title="Category"></span></span> <b>Category</b></li></ul>
</div></td></tr></tbody></table></div>
<div class="navbox-styles"><style data-mw-deduplicate="TemplateStyles:r1038841319">
/* start https://en.wikipedia.org/ */


.mw-parser-output .tooltip-dotted{border-bottom:1px dotted;cursor:help}


/* end https://en.wikipedia.org/ */
</style></div><div role="navigation" class="navbox authority-control" aria-labelledby="Authority_control_databases_frameless&amp;#124;text-top&amp;#124;10px&amp;#124;alt=Edit_this_at_Wikidata&amp;#124;link=https&amp;#58;//www.wikidata.org/wiki/Q188531#identifiers&amp;#124;class=noprint&amp;#124;Edit_this_at_Wikidata1353" style="padding:3px"><table class="nowraplinks hlist mw-collapsible autocollapse navbox-inner" style="border-spacing:0;background:transparent;color:inherit"><tbody><tr><th scope="col" class="navbox-title" colspan="2"><div id="Authority_control_databases_frameless&amp;#124;text-top&amp;#124;10px&amp;#124;alt=Edit_this_at_Wikidata&amp;#124;link=https&amp;#58;//www.wikidata.org/wiki/Q188531#identifiers&amp;#124;class=noprint&amp;#124;Edit_this_at_Wikidata1353" style="font-size:114%;margin:0 4em">Authority control databases </div></th></tr><tr><th scope="row" class="navbox-group" style="width:1%">International</th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em"><ul><li><span class="uid"><a rel="nofollow" class="external text" href="https://id.worldcat.org/fast/1747074">FAST</a></span></li></ul></div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%">National</th><td class="navbox-list-with-group navbox-list navbox-even" style="width:100%;padding:0"><div style="padding:0 0.25em"><ul><li><span class="uid"><a rel="nofollow" class="external text" href="https://d-nb.info/gnd/4335874-3">Germany</a></span></li><li><span class="uid"><a rel="nofollow" class="external text" href="https://id.loc.gov/authorities/sh2008009199">United States</a></span></li><li><span class="uid"><a rel="nofollow" class="external text" href="https://catalogue.bnf.fr/ark:/12148/cb14537421z">France</a></span></li><li><span class="uid"><a rel="nofollow" class="external text" href="https://data.bnf.fr/ark:/12148/cb14537421z">BnF data</a></span></li><li><span class="uid"><span class="rt-commentedText tooltip tooltip-dotted" title="Objective-C (programovací jazyk)"><a rel="nofollow" class="external text" href="https://aleph.nkp.cz/F/?func=find-c&amp;local_base=aut&amp;ccl_term=ica=ph589577&amp;CON_LNG=ENG">Czech Republic</a></span></span></li><li><span class="uid"><a rel="nofollow" class="external text" href="https://www.nli.org.il/en/authorities/987007540185705171">Israel</a></span></li></ul></div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%">Other</th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em"><ul><li><span class="uid"><a rel="nofollow" class="external text" href="https://www.idref.fr/077936582">IdRef</a></span></li><li><span class="uid"><a rel="nofollow" class="external text" href="https://lux.collections.yale.edu/view/concept/16710e38-3148-4a4f-9b9a-f2781e9895e8">Yale LUX</a></span></li></ul></div></td></tr></tbody></table></div></div><!--htdig_noindex--><div><div class="zim-footer">
This article is issued from <a class="external text" title="Last edited on 2025-08-04" href="https://en.wikipedia.org/wiki/?title=Objective-C&amp;oldid=1304128688">Wikipedia</a>. The text is available under <a class="external text" href="https://creativecommons.org/licenses/by-sa/4.0/deed.en">Creative Commons Attribution-Share Alike 4.0</a> unless otherwise noted. Additional terms may apply for the media files.
</div>
</div><!--/htdig_noindex--></div>
</div>
</main>
</div>
</div>
</div>

</body></html>